mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-18 17:11:25 +00:00
## Description When ChatDeepSeek invokes a tool that returns a list, it results in an openai.UnprocessableEntityError due to a failure in deserializing the JSON body. The root of the problem is that ChatDeepSeek uses BaseChatOpenAI internally, but the APIs are not identical: OpenAI v1/chat/completions accepts arrays as tool results, but Deepseek API does not. As a solution added `_get_request_payload` method to ChatDeepSeek, which inherits the behavior from BaseChatOpenAI but adds a step to stringify tool message content in case the content is an array. I also add a unit test for this. From the linked issue you can find the full reproducible example the reporter of the issue provided. After the changes it works as expected. Source: [Deepseek docs](https://api-docs.deepseek.com/api/create-chat-completion/)  Source: [OpenAI docs](https://platform.openai.com/docs/api-reference/chat/create)  ## Issue Fixes #31394 ## Dependencies: No new dependencies. ## Twitter handle: Don't have one. --------- Co-authored-by: Mason Daugherty <github@mdrxy.com> Co-authored-by: Mason Daugherty <mason@langchain.dev> |
||
---|---|---|
.. | ||
integration_tests | ||
unit_tests | ||
__init__.py |