-
Notifications
You must be signed in to change notification settings - Fork 2.1k
OpenAiApi Add support for extraBody and reasoningContent #4309
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
Conversation
SenreySong
commented
Sep 4, 2025
- OpenAiChatOptions.extraBody: Support for custom parameter extension
- ChatCompletionMessage.reasoningContent: Support for reasoning content field
- OpenAiChatOptions.extraBody: Support for custom parameter extension - ChatCompletionMessage.reasoningContent: Support for reasoning content field Signed-off-by: SenreySong <[email protected]>
Signed-off-by: SenreySong <[email protected]>
ee5e0f1 to
bbcb968
Compare
Signed-off-by: Senrey_Song <[email protected]>
- Updated streaming chat response logic to use dynamic request body creation. Signed-off-by: SenreySong <[email protected]>
|
@SenreySong Thanks for the changes. Could you fix(/remove) the formatting changes as part of the PR? This makes it challenging to review the actual changes? |
No problem. I'll fix the formatting issues. |
Signed-off-by: SenreySong <[email protected]> refactor(spring-ai-openai): fix import style Signed-off-by: SenreySong <[email protected]> refactor(spring-ai-openai): fix code style Signed-off-by: SenreySong <[email protected]> refactor(spring-ai-openai): fix code style Signed-off-by: SenreySong <[email protected]>
Signed-off-by: Senrey_Song <[email protected]>
Squashed 17 commits from PR #4309 Signed-off-by: Alexandros Pappas <[email protected]> Signed-off-by: Daniel Garnier-Moiroux <[email protected]> Signed-off-by: Ilayaperumal Gopinathan <[email protected]> Signed-off-by: Mark Pollack <[email protected]> Signed-off-by: SenreySong <[email protected]> Signed-off-by: Senrey_Song <[email protected]> Signed-off-by: Łukasz Jernaś <[email protected]> Refactor extraBody to use @JsonAnyGetter for flat JSON serialization Replace manual JSON merging with Jackson @JsonAnyGetter annotation to flatten extraBody parameters to top-level JSON, matching OpenAI SDK behavior for compatibility with vLLM, Ollama, and other OpenAI-compatible servers. - Add @JsonAnyGetter to extraBody() accessor method - Remove ObjectMapper instance field and createDynamicRequestBody() method - Simplify WebClient calls to use .bodyValue(chatRequest) directly - Add ExtraBodySerializationTest to verify correct flat serialization - Fix unrelated OpenAiSpeechModelIT compilation error
|
@SenreySong Thank you for the PR! This has been merged via ec717c1 |
| return requestNode; | ||
| } | ||
|
|
||
| // 添加额外字段 |
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.
hah
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.
OMG!
|
@ilayaperumalg @SenreySong It seems that the extraBody parameter isn't working in Spring AI 1.1.0. |
|
@Wendell99 Your usage is correct — the issue was that extraBody lacked @JsonProperty, so it got filtered out during merge. Fix submitted. |
|
@SenreySong Your commit has @JsonProperty on extraBody, but it’s not present in v1.1.0 — weird! |
Actually, my commit initially added @JsonProperty, but later reverted to using @JsonAnySetter/@JsonAnyGetter for better flexibility. This change triggered the bug since the merge operation doesn't recognize extraBody as a field to preserve. I've now submitted a fix to explicitly handle extraBody during merging to prevent this issue. |
Squashed 17 commits from PR spring-projects#4309 Signed-off-by: Alexandros Pappas <[email protected]> Signed-off-by: Daniel Garnier-Moiroux <[email protected]> Signed-off-by: Ilayaperumal Gopinathan <[email protected]> Signed-off-by: Mark Pollack <[email protected]> Signed-off-by: SenreySong <[email protected]> Signed-off-by: Senrey_Song <[email protected]> Signed-off-by: Łukasz Jernaś <[email protected]> Refactor extraBody to use @JsonAnyGetter for flat JSON serialization Replace manual JSON merging with Jackson @JsonAnyGetter annotation to flatten extraBody parameters to top-level JSON, matching OpenAI SDK behavior for compatibility with vLLM, Ollama, and other OpenAI-compatible servers. - Add @JsonAnyGetter to extraBody() accessor method - Remove ObjectMapper instance field and createDynamicRequestBody() method - Simplify WebClient calls to use .bodyValue(chatRequest) directly - Add ExtraBodySerializationTest to verify correct flat serialization - Fix unrelated OpenAiSpeechModelIT compilation error Signed-off-by: logan-mac <[email protected]>