Commit 1f9e49c

benny-dou <60535774+benny-dou@users.noreply.github.com>
2026-03-09 07:37:42
style(ai): improves progress message when tool call
1 parent b2ebdfe
Changed files (1)
src
ai
src/ai/texts/tool_call.py
@@ -93,13 +93,16 @@ Use the `web_search` tool to access up-to-date information from the web or when
 """.strip()
     system_prompt = kwargs.get("tool_call_system_prompt", default_system_prompt)
     contexts.insert(0, {"role": "system", "content": system_prompt})
+    show_progress = kwargs.pop("show_progress", True)  # record show_progress value
     kwargs |= {
         "openai_tools": TOOLS,
         "openai_contexts": contexts,
         "openai_system_prompt": system_prompt,
+        "show_progress": False,  # force disable progress message
     }
     resp = await openai_chat_completions(client, message, **kwargs)
-    kwargs["progress"] = kwargs.get("progress") or resp.get("progress") or glom(resp, "sent_messages.0", default=None)
+    if resp.get("tool_name") and show_progress and not kwargs.get("silent") and not isinstance(kwargs.get("progress"), Message):
+        kwargs["progress"] = await message.reply(f"{EMOJI_TEXT_BOT}**{kwargs['model_name']}** 执行工具:\n{resp['tool_name']}", quote=True)
     while resp.get("tool_name"):
         tool_name = resp["tool_name"].strip()
         tool_args = literal_eval(resp.get("tool_args", "{}"))