Skip to content
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

Fix handling of unfinished responses from PA #30

Merged
merged 6 commits into from
Aug 9, 2024
Merged

Conversation

debermudez
Copy link
Contributor

@debermudez debermudez commented Aug 6, 2024

Previously, we were seeing SSE event responses coming back from the model that were not complete.
Complete responses would span multiple responses.
Parsing these responses would fail.
Now we check the responses and merge when necessary to enable correct parsing.

  • Added fix
  • Add unit test with an example offending response set.

Example failing response

{
                                "response": 'data: {"id":"8ae","object":"chat.completion.chunk","created":172,"choices":[{"index":0,"text":" seems","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":5084,"role":"assistant","content":" seems","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text":" like","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":1093,"role":"assistant","content":" like","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text":" you","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":499,"role":"assistant","content":" you","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text":"\'re","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":2351,"role":"assistant","content":"\'re","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text"'
                            },
                            {
                                "response": ':" writing","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":4477,"role":"assistant","content":" writing","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text":" a","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":264,"role":"assistant","content":" a","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text":" letter","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":6661,"role":"assistant","content":" letter","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text":" or","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":477,"role":"assistant","content":" or","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text":" a","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":264,"role":"assistant","content":" a","tool_'
                            },
                            {
                                "response": 'calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text":" passage","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":21765,"role":"assistant","content":" passage","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\ndata: {"id":"8ae835f2ecbb67f3-SJC","object":"chat.completion.chunk","created":1722875835,"choices":[{"index":0,"text":" with","logprobs":null,"finish_reason":null,"seed":null,"delta":{"token_id":449,"role":"assistant","content":" with","tool_calls":null}}],"model":"meta-llama/Llama-3-8b-chat-hf","usage":null}\n\n'
                            },

Closes #27

Copy link
Contributor

@nv-hwoo nv-hwoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@debermudez debermudez merged commit eda567e into main Aug 9, 2024
7 checks passed
@debermudez debermudez deleted the dbermudez-parse-fix branch August 9, 2024 00:15
lkomali pushed a commit that referenced this pull request Aug 15, 2024
* Initial attempt to fix

* Add test for unfinished responses

* Maybe address comments

* formatting

* Update test to validate response format

* Add non sse response test

---------

Co-authored-by: Izzy Putterman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants