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

Common llm response processing #12211

Open
5 tasks done
BillDowney opened this issue Dec 30, 2024 · 1 comment
Open
5 tasks done

Common llm response processing #12211

BillDowney opened this issue Dec 30, 2024 · 1 comment
Labels
🐞 bug Something isn't working

Comments

@BillDowney
Copy link

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.14.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

image
This change causes OpenAI-API-compatible interfaces to return all errors in the [data:] block without Spaces

✔️ Expected Behavior

Return the json data behind the correct data

❌ Actual Behavior

data json formatting error

Copy link

dosubot bot commented Dec 30, 2024

The issue arises from the change in how the prefix "data:" is removed from the string. The original code chunk.strip().lstrip("data:").lstrip() removes all leading characters that are in the set of "d", "a", "t", "a", and ":", which can inadvertently strip additional characters if they appear at the start of the string. The modified code chunk.strip().removeprefix("data:") only removes the exact prefix "data:". If the chunk does not start exactly with "data:", the prefix will not be removed correctly, potentially leaving the JSON data malformed and causing a json.JSONDecodeError when attempting to parse the JSON [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the 🐞 bug Something isn't working label Dec 30, 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
Projects
None yet
Development

No branches or pull requests

1 participant