admin管理员组文章数量:1402832
I have a Spring Boot (version 3.4.2) application with Spring AI and I want to get only JSON responses from OpenAI, so I configured it in my application.yml
file, see Built-in JSON mode:
Some AI Models provide dedicated configuration options to generate structured (usually JSON) output.
- OpenAI Structured Outputs can ensure your model generates responses conforming strictly to your provided JSON Schema. You can choose between the
JSON_OBJECT
that guarantees the message the model generates is valid JSON orJSON_SCHEMA
with a supplied schema that guarantees the model will generate a response that matches your supplied schema (spring.ai.openai.chat.options.responseFormat
option).
Unfortunately, it is not working.
Configuration
spring:
ai:
openai:
chat:
options:
model: gpt-4o-mini
temperature: 0.0
responseFormat: JSON_SCHEMA
Logs
Failed to bind properties under 'spring.ai.openai.chat.options.response-format' to .springframework.ai.openai.api.ResponseFormat:
Reason: .springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [@com.fasterxml.jackson.annotation.JsonProperty .springframework.ai.openai.api.ResponseFormat]
Research
I looked into
ResponseFormat
and ResponseFormat.Type and changedJSON_SCHEMA
tojson_schema
but it didn't help.I read Using the Chat Options Builder and tried to add the response format programmatically. But then I can no longer use
BeanOutputConverter
and have to write the JSON schema manually instead of getting it dynamically from the Java class.
Question
What did I wrong? How can I configure the response format in my application.yml
?
本文标签: spring aiNo converter for orgspringframeworkaiopenaiapiResponseFormatStack Overflow
版权声明:本文标题:spring ai - No converter for org.springframework.ai.openai.api.ResponseFormat - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744363321a2602650.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论