🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -11,7 +11,12 @@ from json_repair import repair_json
|
|||||||
from src.chat.utils.utils import get_chat_type_and_target_info
|
from src.chat.utils.utils import get_chat_type_and_target_info
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from src.chat.message_receive.chat_stream import get_chat_manager
|
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
|
import time
|
||||||
|
|
||||||
logger = get_logger("planner")
|
logger = get_logger("planner")
|
||||||
|
|||||||
@@ -78,7 +78,11 @@ def get_raw_msg_by_timestamp_with_chat_users(
|
|||||||
|
|
||||||
|
|
||||||
def get_actions_by_timestamp_with_chat(
|
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]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""获取在特定聊天从指定时间戳到指定时间戳的动作记录,按时间升序排序,返回动作记录列表"""
|
"""获取在特定聊天从指定时间戳到指定时间戳的动作记录,按时间升序排序,返回动作记录列表"""
|
||||||
query = ActionRecords.select().where(
|
query = ActionRecords.select().where(
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import json
|
import json
|
||||||
import math
|
|
||||||
import random
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from src.chat.message_receive.message import MessageRecv
|
from src.chat.message_receive.message import MessageRecv
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import math
|
|
||||||
import random
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from src.chat.message_receive.message import MessageRecv
|
from src.chat.message_receive.message import MessageRecv
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ class RelationshipFetcher:
|
|||||||
weights = [max(1, min(10, int(point[1]))) for point in current_points]
|
weights = [max(1, min(10, int(point[1]))) for point in current_points]
|
||||||
# 使用加权采样不放回,保证不重复
|
# 使用加权采样不放回,保证不重复
|
||||||
indices = list(range(len(current_points)))
|
indices = list(range(len(current_points)))
|
||||||
selected_indices = set()
|
|
||||||
points = []
|
points = []
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
if not indices:
|
if not indices:
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
import json
|
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
# 导入新插件系统
|
# 导入新插件系统
|
||||||
@@ -12,11 +11,8 @@ from src.common.logger import get_logger
|
|||||||
# 导入API模块 - 标准Python包方式
|
# 导入API模块 - 标准Python包方式
|
||||||
from src.plugin_system.apis import message_api
|
from src.plugin_system.apis import message_api
|
||||||
from src.config.config import global_config
|
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
|
from src.chat.memory_system.Hippocampus import hippocampus_manager
|
||||||
import math
|
import math
|
||||||
from src.chat.utils.utils import is_mentioned_bot_in_message
|
|
||||||
|
|
||||||
|
|
||||||
logger = get_logger("core_actions")
|
logger = get_logger("core_actions")
|
||||||
@@ -91,7 +87,9 @@ class NoReplyAction(BaseAction):
|
|||||||
|
|
||||||
# 2. 检查消息数量是否达到阈值
|
# 2. 检查消息数量是否达到阈值
|
||||||
if new_message_count >= exit_message_count_threshold:
|
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}条新消息,可以考虑一下是否要进行回复"
|
exit_reason = f"{global_config.bot.nickname}(你)看到了{new_message_count}条新消息,可以考虑一下是否要进行回复"
|
||||||
await self.store_action_info(
|
await self.store_action_info(
|
||||||
action_build_into_prompt=False,
|
action_build_into_prompt=False,
|
||||||
@@ -114,11 +112,16 @@ class NoReplyAction(BaseAction):
|
|||||||
action_prompt_display=exit_reason,
|
action_prompt_display=exit_reason,
|
||||||
action_done=True,
|
action_done=True,
|
||||||
)
|
)
|
||||||
return True, f"累计兴趣值达到{accumulated_interest:.2f},结束等待 (等待时间: {elapsed_time:.1f}秒)"
|
return (
|
||||||
|
True,
|
||||||
|
f"累计兴趣值达到{accumulated_interest:.2f},结束等待 (等待时间: {elapsed_time:.1f}秒)",
|
||||||
|
)
|
||||||
|
|
||||||
# 每10秒输出一次等待状态
|
# 每10秒输出一次等待状态
|
||||||
if int(elapsed_time) > 0 and int(elapsed_time) % 10 == 0:
|
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) 来避免在同一秒内重复打印日志
|
# 使用 asyncio.sleep(1) 来避免在同一秒内重复打印日志
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
@@ -141,8 +144,6 @@ class NoReplyAction(BaseAction):
|
|||||||
if not messages_dicts:
|
if not messages_dicts:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
combined_text_parts = []
|
combined_text_parts = []
|
||||||
is_any_mentioned = False
|
is_any_mentioned = False
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ class ReplyAction(BaseAction):
|
|||||||
reply_to = self.action_data.get("reply_to", "")
|
reply_to = self.action_data.get("reply_to", "")
|
||||||
sender, target = self._parse_reply_target(reply_to)
|
sender, target = self._parse_reply_target(reply_to)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
success, reply_set = await asyncio.wait_for(
|
success, reply_set = await asyncio.wait_for(
|
||||||
|
|||||||
Reference in New Issue
Block a user