-
Notifications
You must be signed in to change notification settings - Fork 2.8k
handle data:[DONE]
without space properly
#5580
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
base: main
Are you sure you want to change the base?
Conversation
although https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#request-body says >stream boolean Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message but what I see is `data:[DONE]` (without space), e.g. ``` curl -q --location 'http://localhost:8080/openai/deployments/gpt-4o/chat/completions?api-version=2023-07-01-preview' \ --header 'Authorization: Bearer <token>' \ --header 'X-Forwarded-Client-Cert: secret' \ --header 'Content-Type: application/json' \ --data '{ "stream": true, "messages": [ { "role": "user", "content": "hello." } ] }' data:{"choices":[],"created":0,"id":"","model":"","object":"","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}]} data:{"choices":[{"content_filter_results":{},"delta":{"refusal":null,"role":"assistant"},"finish_reason":null,"index":0}],"created":1746741184,"id":"chatcmpl-BV3SqfEtCuk3f8fW5x7azEkELkJZ0","model":"gpt-4o-2024-05-13","object":"chat.completion.chunk","system_fingerprint":"fp_ee1d74bde0"} ... data:{"choices":[{"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}},"delta":{"content":"?"},"finish_reason":null,"index":0}],"created":1746741184,"id":"chatcmpl-BV3SqfEtCuk3f8fW5x7azEkELkJZ0","model":"gpt-4o-2024-05-13","object":"chat.completion.chunk","system_fingerprint":"fp_ee1d74bde0"} data:{"choices":[{"content_filter_results":{},"delta":{},"finish_reason":"stop","index":0}],"created":1746741184,"id":"chatcmpl-BV3SqfEtCuk3f8fW5x7azEkELkJZ0","model":"gpt-4o-2024-05-13","object":"chat.completion.chunk","system_fingerprint":"fp_ee1d74bde0"} data:[DONE] ```
✅ Deploy Preview for continuedev canceled.
|
Thanks for the fix here @zyxue ! I merged main to resolve the issue with failing e2e tests. |
Failing test was due to rate limiting, not an issue with the PR |
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.
@zyxue Are you able to add a test or two to lock down this behavior? I think it should luckily be pretty quick to do by making core/llm/stream.test.ts
and adding a few important cases with Jest
what's the relationship between the |
I'm not very fluent with typescript, does that require prefixing |
@zyxue looks like tests are failing in CI due to a few syntax errors: https://github.com/continuedev/continue/actions/runs/14976915270/job/42071499598?pr=5580#step:8:9 |
although https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#request-body says
but what I see is
data:[DONE]
(without space), e.g.Description
handle the last chunk of AzureOpenAI streaming chat completion response more robustly.
Checklist
Screenshots
[ For visual changes, include screenshots. Screen recordings are particularly helpful, and appreciated! ]
Testing instructions
[ For new or modified features, provide step-by-step testing instructions to validate the intended behavior of the change, including any relevant tests to run. ]
Summary by mrge
Fixed parsing of server-sent events to handle both "data:[DONE]" (no space) and "data: [DONE]" (with space) as valid stream end markers.