-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Lacks support for annotations
field in OpenAI's chat completion object
#2449
Comments
The problem is very serious. |
apappascs
added a commit
to apappascs/spring-ai
that referenced
this issue
Mar 13, 2025
This PR adds support for retrieving web search annotations from the OpenAI API, as described in their [web search documentation](https://platform.openai.com/docs/guides/web-search). This allows us to access citation URLs and their context within generated responses when using models like `gpt-4o-search-preview`. **Changes:** * Added `annotations` (with `Annotation` and `UrlCitation` records) to `ChatCompletionMessage` in `OpenAiApi.java`. * Updated `OpenAiChatModel` to populate the `annotations` field (via metadata) for both regular and streaming responses. * Added integration tests (`webSearchAnnotationsTest`, `streamWebSearchAnnotationsTest`) to `OpenAiChatModelIT.java`. * Added `GPT_4_O_SEARCH_PREVIEW` and `GPT_4_O_MINI_SEARCH_PREVIEW` to `OpenAiApi.ChatModel`. * Added `WebSearchOptions` and related records to `OpenAiApi`. * Minor updates to `ChatCompletionRequest` and its `Builder`. Resolves spring-projects#2449 Signed-off-by: Alexandros Pappas <[email protected]>
As a temporary workaround, add this objectMapper to your main class
|
@zainlateef yeah! I have done that in my project, but I just happened to see it, so I reported it here 😄 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:
Bug description
Lacks support for
annotations
field in OpenAI'schat completion object
(underchat completion object > message > annotations
)https://platform.openai.com/docs/api-reference/chat/object
Environment
org.springframework.ai:spring-ai-bom:1.0.0-M6
Steps to reproduce
Expected behavior
Minimal Complete Reproducible example
N/A
Ref:
spring-ai/models/spring-ai-openai/src/main/java/org/springframework/ai/openai/api/OpenAiApi.java
Lines 1054 to 1063 in 66e8d88
The text was updated successfully, but these errors were encountered: