🤖 自动格式化代码 [skip ci]

This commit is contained in:
github-actions[bot]
2025-07-10 17:32:15 +00:00
parent 44abb71959
commit 3768fb22ad
7 changed files with 30 additions and 27 deletions

View File

@@ -11,7 +11,12 @@ from json_repair import repair_json
from src.chat.utils.utils import get_chat_type_and_target_info
from datetime import datetime
from src.chat.message_receive.chat_stream import get_chat_manager
from src.chat.utils.chat_message_builder import build_readable_actions, build_readable_messages, get_actions_by_timestamp_with_chat, get_raw_msg_before_timestamp_with_chat
from src.chat.utils.chat_message_builder import (
build_readable_actions,
build_readable_messages,
get_actions_by_timestamp_with_chat,
get_raw_msg_before_timestamp_with_chat,
)
import time
logger = get_logger("planner")

View File

@@ -78,7 +78,11 @@ def get_raw_msg_by_timestamp_with_chat_users(
def get_actions_by_timestamp_with_chat(
chat_id: str, timestamp_start: float = 0, timestamp_end: float = time.time(), limit: int = 0, limit_mode: str = "latest"
chat_id: str,
timestamp_start: float = 0,
timestamp_end: float = time.time(),
limit: int = 0,
limit_mode: str = "latest",
) -> List[Dict[str, Any]]:
"""获取在特定聊天从指定时间戳到指定时间戳的动作记录,按时间升序排序,返回动作记录列表"""
query = ActionRecords.select().where(

View File

@@ -1,6 +1,4 @@
import json
import math
import random
import time
from src.chat.message_receive.message import MessageRecv

View File

@@ -1,7 +1,5 @@
import asyncio
import json
import math
import random
import time
from src.chat.message_receive.message import MessageRecv

View File

@@ -126,7 +126,6 @@ class RelationshipFetcher:
weights = [max(1, min(10, int(point[1]))) for point in current_points]
# 使用加权采样不放回,保证不重复
indices = list(range(len(current_points)))
selected_indices = set()
points = []
for _ in range(3):
if not indices:

View File

@@ -1,6 +1,5 @@
import random
import time
import json
from typing import Tuple
# 导入新插件系统
@@ -12,11 +11,8 @@ from src.common.logger import get_logger
# 导入API模块 - 标准Python包方式
from src.plugin_system.apis import message_api
from src.config.config import global_config
from src.chat.message_receive.message import MessageRecv
from src.chat.message_receive.chat_stream import get_chat_manager
from src.chat.memory_system.Hippocampus import hippocampus_manager
import math
from src.chat.utils.utils import is_mentioned_bot_in_message
logger = get_logger("core_actions")
@@ -91,7 +87,9 @@ class NoReplyAction(BaseAction):
# 2. 检查消息数量是否达到阈值
if new_message_count >= exit_message_count_threshold:
logger.info(f"{self.log_prefix} 累计消息数量达到{new_message_count}条(>{exit_message_count_threshold}),结束等待")
logger.info(
f"{self.log_prefix} 累计消息数量达到{new_message_count}条(>{exit_message_count_threshold}),结束等待"
)
exit_reason = f"{global_config.bot.nickname}(你)看到了{new_message_count}条新消息,可以考虑一下是否要进行回复"
await self.store_action_info(
action_build_into_prompt=False,
@@ -114,11 +112,16 @@ class NoReplyAction(BaseAction):
action_prompt_display=exit_reason,
action_done=True,
)
return True, f"累计兴趣值达到{accumulated_interest:.2f},结束等待 (等待时间: {elapsed_time:.1f}秒)"
return (
True,
f"累计兴趣值达到{accumulated_interest:.2f},结束等待 (等待时间: {elapsed_time:.1f}秒)",
)
# 每10秒输出一次等待状态
if int(elapsed_time) > 0 and int(elapsed_time) % 10 == 0:
logger.debug(f"{self.log_prefix} 已等待{elapsed_time:.0f}秒,累计{new_message_count}条消息,继续等待...")
logger.debug(
f"{self.log_prefix} 已等待{elapsed_time:.0f}秒,累计{new_message_count}条消息,继续等待..."
)
# 使用 asyncio.sleep(1) 来避免在同一秒内重复打印日志
await asyncio.sleep(1)
@@ -141,8 +144,6 @@ class NoReplyAction(BaseAction):
if not messages_dicts:
return 0.0
combined_text_parts = []
is_any_mentioned = False

View File

@@ -75,8 +75,6 @@ class ReplyAction(BaseAction):
reply_to = self.action_data.get("reply_to", "")
sender, target = self._parse_reply_target(reply_to)
try:
try:
success, reply_set = await asyncio.wait_for(