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 bug:support streaming mode content start with "data:" #12171

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jifei
Copy link

@jifei jifei commented Dec 27, 2024

Summary

When deploying LLM with ms-swift, the streaming data returned does not consistently start with "data: ". Specifically, the data does not include a leading space after "data:". This inconsistency stems from the pull request #11272 return failed,the version of Dify before 0.13.0 is ok. To address this, my code has been updated to support both formats: "data:" and "data: "

streaming content e.g.
"data:{"model": "my-llm", "choices": [{"index": 0, "delta": {"role": "assistant", "content": "Hello! How ", "tool_calls": null}, "finish_reason": null, "logprobs": null}], "usage": {"prompt_tokens": 30, "completion_tokens": 7, "total_tokens": 37}, "id": "chatcmpl-d802c95d766a41a5bf9491aafdba2b36", "object": "chat.completion.chunk", "created": 1735303124}"

Fixes #12143

Screenshots

Before
image

After
image

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. ⚙️ feat:model-runtime labels Dec 27, 2024
@jifei jifei marked this pull request as draft December 27, 2024 15:18
@jifei jifei changed the title support steaming mode content start with data: fix bug:support steaming mode content start with data: Dec 27, 2024
@jifei jifei marked this pull request as ready for review December 27, 2024 15:27
@dosubot dosubot bot added the 🐞 bug Something isn't working label Dec 27, 2024
@jifei jifei changed the title fix bug:support steaming mode content start with data: fix bug:support streaming mode content start with data: Dec 27, 2024
@jifei jifei changed the title fix bug:support streaming mode content start with data: fix bug:support streaming mode content start with data: Dec 27, 2024
@jifei jifei changed the title fix bug:support streaming mode content start with data: fix bug:support streaming mode content start with "data:" Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working ⚙️ feat:model-runtime size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAI-API-compatible model not support streaming mode
1 participant