Skip to content

Commit 8326985

Browse files
committed
Fix JsonSchemaGenerator for method input parameters
- For method input parameters, if the JSON schema generator adds OpenAPI "format" property, some LLMs (ex: Mistral) fail to process the request. Hence, removing this specific property from the JSON schema - This issue was uncovered by MistralAiChatModelIT#chatMemoryWithTools where the method toolcallback is used Signed-off-by: Ilayaperumal Gopinathan <[email protected]>
1 parent 4408c46 commit 8326985

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

spring-ai-model/src/main/java/org/springframework/ai/util/json/schema/JsonSchemaGenerator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public static String generateForMethodInput(Method method, SchemaOption... schem
140140
required.add(parameterName);
141141
}
142142
ObjectNode parameterNode = SUBTYPE_SCHEMA_GENERATOR.generateSchema(parameterType);
143+
// Remove OpenAPI format as some LLMs (like Mistral) don't handle them.
144+
parameterNode.remove("format");
143145
String parameterDescription = getMethodParameterDescription(method, i);
144146
if (StringUtils.hasText(parameterDescription)) {
145147
parameterNode.put("description", parameterDescription);

0 commit comments

Comments
 (0)