-
Notifications
You must be signed in to change notification settings - Fork 16.3k
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
[Exception Handling] DeepSeek JSONDecodeError #29758
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
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.
This is a problem with DeepSeek. I don't think we should handle this in langchain-openai (there are many providers who subclass BaseChatOpenAI, it's not tenable to account for these possibilities for all providers).
What do you think about implementing this on ChatDeepSeek-- e.g., overriding _stream
and other methods and handling exceptions when you call super()._stream
?
Aha, thank you @ccurme, I didn't know that it is used by others other than Openai and Deepseek. You are absolutely right about your concern. I will make the suggested changes and revert the BaseChatOpenAI changes. |
…ch for meaningful output" This reverts commit 4bd23d6.
@ccurme I have made the changes as suggested. However, I need an advice here: Should I raise the error as ValueError as we have it from the parent class or JSONDecodeError? please note I did a small refactor in the function |
For Context please check #29626
The Deepseek is using langchain_openai. The error happens that it show
json decode error
.I added a handler for this to give a more sensible error message which is DeepSeek API returned empty/invalid json.
Reproducing the issue is a bit challenging as it is inconsistent, sometimes DeepSeek returns valid data and in other times it returns invalid data which triggers the JSON Decode Error.
This PR is an exception handling, but not an ultimate fix for the issue.