mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-24 13:26:08 +00:00
fix: in the localagent.py yield MessageChunk add agr tool_calls,and After calling the "tool_calls", the first returned body data will be concatenated.
This commit is contained in:
@@ -248,6 +248,7 @@ class ModelScopeChatCompletions(requester.ProviderAPIRequester):
|
|||||||
if hasattr(chunk, 'choices') and chunk.choices:
|
if hasattr(chunk, 'choices') and chunk.choices:
|
||||||
choice = chunk.choices[0]
|
choice = chunk.choices[0]
|
||||||
delta = choice.delta.model_dump() if hasattr(choice, 'delta') else {}
|
delta = choice.delta.model_dump() if hasattr(choice, 'delta') else {}
|
||||||
|
print(delta)
|
||||||
finish_reason = getattr(choice, 'finish_reason', None)
|
finish_reason = getattr(choice, 'finish_reason', None)
|
||||||
else:
|
else:
|
||||||
delta = {}
|
delta = {}
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ class LocalAgentRunner(runner.RequestRunner):
|
|||||||
yield llm_entities.MessageChunk(
|
yield llm_entities.MessageChunk(
|
||||||
role=last_role,
|
role=last_role,
|
||||||
content=accumulated_content, # 输出所有累积内容
|
content=accumulated_content, # 输出所有累积内容
|
||||||
|
tool_calls=list(tool_calls_map.values()) if (tool_calls_map and msg.is_final) else None,
|
||||||
is_final=msg.is_final,
|
is_final=msg.is_final,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -166,6 +167,7 @@ class LocalAgentRunner(runner.RequestRunner):
|
|||||||
)
|
)
|
||||||
|
|
||||||
pending_tool_calls = final_msg.tool_calls
|
pending_tool_calls = final_msg.tool_calls
|
||||||
|
first_content = final_msg.content
|
||||||
|
|
||||||
req_messages.append(final_msg)
|
req_messages.append(final_msg)
|
||||||
|
|
||||||
@@ -222,6 +224,10 @@ class LocalAgentRunner(runner.RequestRunner):
|
|||||||
if msg.role:
|
if msg.role:
|
||||||
last_role = msg.role
|
last_role = msg.role
|
||||||
|
|
||||||
|
# 第一次请求工具调用时的内容
|
||||||
|
if msg_idx == 1:
|
||||||
|
accumulated_content =first_content if first_content is not None else accumulated_content
|
||||||
|
|
||||||
# 累积内容
|
# 累积内容
|
||||||
if msg.content:
|
if msg.content:
|
||||||
accumulated_content += msg.content
|
accumulated_content += msg.content
|
||||||
|
|||||||
Reference in New Issue
Block a user