mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-25 19:37:36 +08:00
Bugfix (#1482)
* Update modelscopechatcmpl.py tool_call 流式输出的最后一个参数是 None,需要判断一下 * Update mcp.py 问题:闭包(closure)对循环变量 tool 的捕获,导致最终注册到 self.functions 里的所有 func,都会引用 同一个(最后一个)tool 解决:在定义 func 时,通过函数参数的 默认值 把当下的 tool “冻结”住 * Update mcp.py
This commit is contained in:
@@ -57,6 +57,8 @@ class ModelScopeChatCompletions(requester.LLMAPIRequester):
|
||||
|
||||
if chunk.choices[0].delta.tool_calls is not None:
|
||||
for tool_call in chunk.choices[0].delta.tool_calls:
|
||||
if tool_call.function.arguments is None:
|
||||
continue
|
||||
for tc in tool_calls:
|
||||
if tc.index == tool_call.index:
|
||||
tc.function.arguments += tool_call.function.arguments
|
||||
|
||||
@@ -82,8 +82,8 @@ class RuntimeMCPSession:
|
||||
|
||||
for tool in tools.tools:
|
||||
|
||||
async def func(query: core_entities.Query, **kwargs):
|
||||
result = await self.session.call_tool(tool.name, kwargs)
|
||||
async def func(query: core_entities.Query, *, _tool=tool, **kwargs):
|
||||
result = await self.session.call_tool(_tool.name, kwargs)
|
||||
if result.isError:
|
||||
raise Exception(result.content[0].text)
|
||||
return result.content[0].text
|
||||
|
||||
Reference in New Issue
Block a user