From ea635fd147a381bb6cc814b5e8708b5e5837122d Mon Sep 17 00:00:00 2001 From: FuQuan233 Date: Wed, 20 Aug 2025 12:38:39 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=E7=BB=99llm?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_llmchat/__init__.py | 2 +- nonebot_plugin_llmchat/mcpclient.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/nonebot_plugin_llmchat/__init__.py b/nonebot_plugin_llmchat/__init__.py index d0d5857..0d0feae 100755 --- a/nonebot_plugin_llmchat/__init__.py +++ b/nonebot_plugin_llmchat/__init__.py @@ -315,7 +315,7 @@ async def process_messages(group_id: int): # 将机器人错过的消息推送给LLM past_events_snapshot = list(state.past_events) for ev in past_events_snapshot: - text_content = ",".join([format_message(ev) for ev in past_events_snapshot]) + text_content = format_message(ev) content.append({"type": "text", "text": text_content}) # 将消息中的图片转成 base64 diff --git a/nonebot_plugin_llmchat/mcpclient.py b/nonebot_plugin_llmchat/mcpclient.py index 9ed9fe0..a6c6ff3 100644 --- a/nonebot_plugin_llmchat/mcpclient.py +++ b/nonebot_plugin_llmchat/mcpclient.py @@ -1,5 +1,5 @@ -from contextlib import AsyncExitStack import asyncio +from contextlib import AsyncExitStack from mcp import ClientSession, StdioServerParameters from mcp.client.sse import sse_client @@ -66,9 +66,7 @@ class MCPClient: logger.info(f"正在服务器[{server_name}]上调用工具[{real_tool_name}]") session = self.sessions[server_name] try: - response = await asyncio.wait_for( - session.call_tool(real_tool_name, tool_args), timeout=10 - ) + response = await asyncio.wait_for(session.call_tool(real_tool_name, tool_args), timeout=10) except asyncio.TimeoutError: logger.error(f"调用工具[{real_tool_name}]超时") return f"调用工具[{real_tool_name}]超时"