Pārlūkot izejas kodu

调整多模态支持

liuchengsen 1 mēnesi atpakaļ
vecāks
revīzija
66b6d8ff2b

+ 9 - 13
backend-java/src/main/java/com/pharmacopoeia/service/LLMService.java

@@ -115,11 +115,10 @@ public class LLMService {
                 """;
         }
 
-        // 构建 vision 消息(多模态 content 数组
+        // 构建 vision 消息(DashScope 原生多模态格式
         List<Map<String, Object>> contentParts = List.of(
-                Map.of("type", "image_url",
-                       "image_url", Map.of("url", "data:" + mimeType + ";base64," + imageBase64)),
-                Map.of("type", "text", "text", prompt)
+                Map.of("image", "data:" + mimeType + ";base64," + imageBase64),
+                Map.of("text", prompt)
         );
 
         Map<String, Object> userMessage = Map.of("role", "user", "content", contentParts);
@@ -154,9 +153,8 @@ public class LLMService {
         }
 
         List<Map<String, Object>> contentParts = List.of(
-                Map.of("type", "image_url",
-                       "image_url", Map.of("url", "data:" + mimeType + ";base64," + imageBase64)),
-                Map.of("type", "text", "text", prompt)
+                Map.of("image", "data:" + mimeType + ";base64," + imageBase64),
+                Map.of("text", prompt)
         );
 
         Map<String, Object> userMessage = Map.of("role", "user", "content", contentParts);
@@ -192,9 +190,8 @@ public class LLMService {
         }
 
         List<Map<String, Object>> contentParts = List.of(
-                Map.of("type", "video_url",
-                       "video_url", Map.of("url", "data:" + mimeType + ";base64," + videoBase64)),
-                Map.of("type", "text", "text", prompt)
+                Map.of("video", "data:" + mimeType + ";base64," + videoBase64),
+                Map.of("text", prompt)
         );
 
         Map<String, Object> userMessage = Map.of("role", "user", "content", contentParts);
@@ -226,9 +223,8 @@ public class LLMService {
         }
 
         List<Map<String, Object>> contentParts = List.of(
-                Map.of("type", "video_url",
-                       "video_url", Map.of("url", "data:" + mimeType + ";base64," + videoBase64)),
-                Map.of("type", "text", "text", prompt)
+                Map.of("video", "data:" + mimeType + ";base64," + videoBase64),
+                Map.of("text", prompt)
         );
 
         Map<String, Object> userMessage = Map.of("role", "user", "content", contentParts);