mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 12:05:54 +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:
|
||||
choice = chunk.choices[0]
|
||||
delta = choice.delta.model_dump() if hasattr(choice, 'delta') else {}
|
||||
print(delta)
|
||||
finish_reason = getattr(choice, 'finish_reason', None)
|
||||
else:
|
||||
delta = {}
|
||||
|
||||
@@ -155,6 +155,7 @@ class LocalAgentRunner(runner.RequestRunner):
|
||||
yield llm_entities.MessageChunk(
|
||||
role=last_role,
|
||||
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,
|
||||
)
|
||||
|
||||
@@ -166,6 +167,7 @@ class LocalAgentRunner(runner.RequestRunner):
|
||||
)
|
||||
|
||||
pending_tool_calls = final_msg.tool_calls
|
||||
first_content = final_msg.content
|
||||
|
||||
req_messages.append(final_msg)
|
||||
|
||||
@@ -222,6 +224,10 @@ class LocalAgentRunner(runner.RequestRunner):
|
||||
if 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:
|
||||
accumulated_content += msg.content
|
||||
|
||||
Reference in New Issue
Block a user