From 5f384da4894799107cf177c49f336ce8944a8abb Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Sat, 1 Nov 2025 19:31:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor(chat):=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E6=97=A5=E7=A8=8B=E7=8A=B6=E6=80=81=E6=8F=90=E7=A4=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除了在日程活动时间范围之外的冗余状态判断。现在,无论当前时间是否在活动时间段内,都会统一计算并展示活动的开始、结束、已进行和剩余时间,简化了代码逻辑并确保了信息展示的一致性。反正LLM自己会判断的,不需要咱操心那么多啦。 --- src/chat/replyer/default_generator.py | 9 +++------ src/llm_models/model_client/openai_client.py | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/chat/replyer/default_generator.py b/src/chat/replyer/default_generator.py index 106295ca9..5b214aade 100644 --- a/src/chat/replyer/default_generator.py +++ b/src/chat/replyer/default_generator.py @@ -1468,18 +1468,15 @@ class DefaultReplyer: if now < start_time: now += timedelta(days=1) - if start_time <= now < end_time: - duration_minutes = (now - start_time).total_seconds() / 60 - remaining_minutes = (end_time - now).total_seconds() / 60 - schedule_block = ( + duration_minutes = (now - start_time).total_seconds() / 60 + remaining_minutes = (end_time - now).total_seconds() / 60 + schedule_block = ( f"你当前正在进行“{activity}”," f"计划时间从{start_time.strftime('%H:%M')}到{end_time.strftime('%H:%M')}。" f"这项活动已经开始了{duration_minutes:.0f}分钟," f"预计还有{remaining_minutes:.0f}分钟结束。" "(此为你的当前状态,仅供参考。除非被直接询问,否则不要在对话中主动提及。)" ) - else: - schedule_block = f"你当前正在进行“{activity}”。(此为你的当前状态,仅供参考。除非被直接询问,否则不要在对话中主动提及。)" except (ValueError, AttributeError): schedule_block = f"你当前正在进行“{activity}”。(此为你的当前状态,仅供参考。除非被直接询问,否则不要在对话中主动提及。)" diff --git a/src/llm_models/model_client/openai_client.py b/src/llm_models/model_client/openai_client.py index 3b6055b45..efa1785d9 100644 --- a/src/llm_models/model_client/openai_client.py +++ b/src/llm_models/model_client/openai_client.py @@ -350,10 +350,10 @@ def _default_normal_response_parser( api_response.tool_calls = [] for call in message_part.tool_calls: try: - arguments = orjson.loads(repair_json(call.function.arguments)) + arguments = orjson.loads(repair_json(call.function.arguments)) # type: ignore if not isinstance(arguments, dict): raise RespParseException(resp, "响应解析失败,工具调用参数无法解析为字典类型") - api_response.tool_calls.append(ToolCall(call.id, call.function.name, arguments)) + api_response.tool_calls.append(ToolCall(call.id, call.function.name, arguments)) # type: ignore except orjson.JSONDecodeError as e: raise RespParseException(resp, "响应解析失败,无法解析工具调用参数") from e From e0063fb281eebe2773f18d73a72168fb5d2444f0 Mon Sep 17 00:00:00 2001 From: Windpicker-owo <3431391539@qq.com> Date: Sat, 1 Nov 2025 19:34:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E5=9C=A8=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E6=B5=81=E6=97=B6=E6=B7=BB=E5=8A=A0=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=97=B6=E9=97=B4=E5=92=8C=E6=9C=80=E5=90=8E=E6=B4=BB?= =?UTF-8?q?=E8=B7=83=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/message_receive/chat_stream.py | 3 +++ src/person_info/relationship_fetcher.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/chat/message_receive/chat_stream.py b/src/chat/message_receive/chat_stream.py index 782ff757b..4e583e8e7 100644 --- a/src/chat/message_receive/chat_stream.py +++ b/src/chat/message_receive/chat_stream.py @@ -444,10 +444,13 @@ class ChatManager: return stream # 使用优化后的API查询(带缓存) + current_time = time.time() model_instance, _ = await get_or_create_chat_stream( stream_id=stream_id, platform=platform, defaults={ + "create_time": current_time, + "last_active_time": current_time, "user_platform": user_info.platform if user_info else platform, "user_id": user_info.user_id if user_info else "", "user_nickname": user_info.user_nickname if user_info else "", diff --git a/src/person_info/relationship_fetcher.py b/src/person_info/relationship_fetcher.py index fbf98436f..d2e61467c 100644 --- a/src/person_info/relationship_fetcher.py +++ b/src/person_info/relationship_fetcher.py @@ -257,14 +257,20 @@ class RelationshipFetcher: """ try: from src.common.database.api.specialized import get_or_create_chat_stream + import time # 使用优化后的API(带缓存) # 从stream_id解析platform,或使用默认值 platform = stream_id.split("_")[0] if "_" in stream_id else "unknown" + current_time = time.time() stream, _ = await get_or_create_chat_stream( stream_id=stream_id, platform=platform, + defaults={ + "create_time": current_time, + "last_active_time": current_time, + }, ) if not stream: From f91acbb20294a4030bbd35aee3cbe214f9c8aa31 Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Sat, 1 Nov 2025 19:36:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix(plugin=5Fsystem):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=A4=E6=AD=A5=E5=B7=A5=E5=85=B7=E5=AE=9A=E4=B9=89=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B=E6=B3=A8=E8=A7=A3=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 `definitions` 的类型注解从 `ClassVar` 移除,因为它是一个在方法内部构建并返回的局部变量,而不是一个类变量。这修正了潜在的类型检查错误,并使代码意图更加清晰。 --- src/plugin_system/base/base_tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin_system/base/base_tool.py b/src/plugin_system/base/base_tool.py index fcb2bfe17..dafccad17 100644 --- a/src/plugin_system/base/base_tool.py +++ b/src/plugin_system/base/base_tool.py @@ -112,7 +112,7 @@ class BaseTool(ABC): if not cls.is_two_step_tool: return [] - definitions: ClassVar = [] + definitions = [] for sub_name, sub_desc, sub_params in cls.sub_tools: definitions.append({"name": f"{cls.name}_{sub_name}", "description": sub_desc, "parameters": sub_params}) return definitions