mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-03 19:57:51 +00:00
community: [fix] add missing tool_calls kwargs of delta message in openai adapter (#27492)
- **Description:** add missing tool_calls kwargs of delta message in openai adapter, then tool call will work correctly via adapter's stream chat completion - **Issue:** Fixes https://github.com/langchain-ai/langchain/issues/25436 - **Dependencies:** None
This commit is contained in:
parent
25a1031871
commit
621f78babd
@ -180,6 +180,12 @@ def _convert_message_chunk(chunk: BaseMessageChunk, i: int) -> dict:
|
||||
# not missing, but None.
|
||||
if i == 0:
|
||||
_dict["content"] = None
|
||||
if "tool_calls" in chunk.additional_kwargs:
|
||||
_dict["tool_calls"] = chunk.additional_kwargs["tool_calls"]
|
||||
# If the first chunk is tool calls, the content is not empty string,
|
||||
# not missing, but None.
|
||||
if i == 0:
|
||||
_dict["content"] = None
|
||||
else:
|
||||
_dict["content"] = chunk.content
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user