-
Notifications
You must be signed in to change notification settings - Fork 87
feat: 为评估项新增超时时间与默认值配置 #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |||||
| import org.springframework.ai.chat.messages.UserMessage; | ||||||
| import org.springframework.ai.chat.model.ChatModel; | ||||||
| import org.springframework.ai.chat.model.ChatResponse; | ||||||
| import org.springframework.ai.chat.prompt.ChatOptions; | ||||||
| import org.springframework.ai.chat.prompt.Prompt; | ||||||
| import org.springframework.ai.content.Media; | ||||||
|
|
||||||
|
|
@@ -49,6 +50,7 @@ public class MultimodalLLMBasedEvaluator extends LLMBasedEvaluator { | |||||
| private static final Logger logger = LoggerFactory.getLogger(MultimodalLLMBasedEvaluator.class); | ||||||
|
|
||||||
| private final ChatModel multimodalChatModel; | ||||||
| private final ChatOptions multimodalChatOptions; | ||||||
|
|
||||||
| /** | ||||||
| * 用于将 Map 转换为 MediaConvertible 实现类的 ObjectMapper | ||||||
|
|
@@ -69,7 +71,21 @@ public class MultimodalLLMBasedEvaluator extends LLMBasedEvaluator { | |||||
| * @param evaluatorId 评估器ID | ||||||
| */ | ||||||
| public MultimodalLLMBasedEvaluator(ChatModel textModel, ChatModel multimodalModel, String evaluatorId) { | ||||||
| this(textModel, multimodalModel, evaluatorId, createDefaultObjectMapper()); | ||||||
| this(textModel, multimodalModel, evaluatorId, null, null, createDefaultObjectMapper()); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * 构造函数(带 ChatOptions) | ||||||
| * | ||||||
| * @param textModel 纯文本模型,用于普通评估 | ||||||
| * @param multimodalModel 多模态模型,用于处理图片等多模态输入 | ||||||
| * @param evaluatorId 评估器ID | ||||||
| * @param textChatOptions 纯文本模型的ChatOptions(可选) | ||||||
| * @param multimodalChatOptions 多模态模型的ChatOptions(可选) | ||||||
| */ | ||||||
| public MultimodalLLMBasedEvaluator(ChatModel textModel, ChatModel multimodalModel, String evaluatorId, | ||||||
| ChatOptions textChatOptions, ChatOptions multimodalChatOptions) { | ||||||
| this(textModel, multimodalModel, evaluatorId, textChatOptions, multimodalChatOptions, createDefaultObjectMapper()); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -93,8 +109,24 @@ private static ObjectMapper createDefaultObjectMapper() { | |||||
| */ | ||||||
| public MultimodalLLMBasedEvaluator(ChatModel textModel, ChatModel multimodalModel, | ||||||
| String evaluatorId, ObjectMapper objectMapper) { | ||||||
| super(textModel, evaluatorId); | ||||||
| this(textModel, multimodalModel, evaluatorId, null, null, objectMapper); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * 构造函数(完整参数) | ||||||
| * | ||||||
| * @param textModel 纯文本模型,用于普通评估 | ||||||
| * @param multimodalModel 多模态模型,用于处理图片等多模态输入 | ||||||
| * @param evaluatorId 评估器ID | ||||||
| * @param textChatOptions 纯文本模型的ChatOptions(可选) | ||||||
| * @param multimodalChatOptions 多模态模型的ChatOptions(可选) | ||||||
| * @param objectMapper 用于类型转换的 ObjectMapper | ||||||
| */ | ||||||
| public MultimodalLLMBasedEvaluator(ChatModel textModel, ChatModel multimodalModel, String evaluatorId, | ||||||
| ChatOptions textChatOptions, ChatOptions multimodalChatOptions, ObjectMapper objectMapper) { | ||||||
| super(textModel, evaluatorId, textChatOptions); | ||||||
| this.multimodalChatModel = multimodalModel; | ||||||
| this.multimodalChatOptions = multimodalChatOptions; | ||||||
| this.objectMapper = objectMapper != null ? objectMapper : new ObjectMapper(); | ||||||
|
||||||
| this.objectMapper = objectMapper != null ? objectMapper : new ObjectMapper(); | |
| this.objectMapper = objectMapper != null ? objectMapper : createDefaultObjectMapper(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the JSON-serialization fallback, the string is wrapped with normal quotes but newlines aren’t handled. If
value.toString()contains '\n', the generated Python literal becomes invalid code. Reuse the same multiline-safe escaping logic as the String branch (triple quotes when needed) for this fallback path too.