This commit is contained in:
春河晴
2025-06-10 16:18:57 +09:00
parent 8d9a88a903
commit 2edece11ea
6 changed files with 9 additions and 18 deletions

View File

@@ -125,6 +125,8 @@ class DatabaseAPI:
) )
""" """
try: try:
if query_type not in ["get", "create", "update", "delete", "count"]:
raise ValueError("query_type must be 'get' or 'create' or 'update' or 'delete' or 'count'")
# 构建基本查询 # 构建基本查询
if query_type in ["get", "update", "delete", "count"]: if query_type in ["get", "update", "delete", "count"]:
query = model_class.select() query = model_class.select()
@@ -198,7 +200,7 @@ class DatabaseAPI:
return None if single_result else [] return None if single_result else []
elif query_type in ["create", "update", "delete", "count"]: elif query_type in ["create", "update", "delete", "count"]:
return None return None
raise "unknown query type" return None
async def db_raw_query( async def db_raw_query(
self, sql: str, params: List[Any] = None, fetch_results: bool = True self, sql: str, params: List[Any] = None, fetch_results: bool = True

View File

@@ -53,7 +53,7 @@ class MessageAPI:
if is_group: if is_group:
# 群聊:从数据库查找对应的聊天流 # 群聊:从数据库查找对应的聊天流
target_stream = None target_stream = None
for stream_id, stream in chat_manager.streams.items(): for _, stream in chat_manager.streams.items():
if ( if (
stream.group_info stream.group_info
and str(stream.group_info.group_id) == str(target_id) and str(stream.group_info.group_id) == str(target_id)
@@ -68,7 +68,7 @@ class MessageAPI:
else: else:
# 私聊:从数据库查找对应的聊天流 # 私聊:从数据库查找对应的聊天流
target_stream = None target_stream = None
for stream_id, stream in chat_manager.streams.items(): for _, stream in chat_manager.streams.items():
if ( if (
not stream.group_info not stream.group_info
and str(stream.user_info.user_id) == str(target_id) and str(stream.user_info.user_id) == str(target_id)
@@ -87,7 +87,6 @@ class MessageAPI:
# 生成消息ID和thinking_id # 生成消息ID和thinking_id
current_time = time.time() current_time = time.time()
message_id = f"plugin_msg_{int(current_time * 1000)}" message_id = f"plugin_msg_{int(current_time * 1000)}"
thinking_id = f"plugin_thinking_{int(current_time * 1000)}"
# 构建机器人用户信息 # 构建机器人用户信息
bot_user_info = UserInfo( bot_user_info = UserInfo(

View File

@@ -140,12 +140,12 @@ class ExpressionLearner:
continue continue
# 学习新的表达方式(这里会进行局部衰减) # 学习新的表达方式(这里会进行局部衰减)
for i in range(3): for _ in range(3):
learnt_style: Optional[List[Tuple[str, str, str]]] = await self.learn_and_store(type="style", num=25) learnt_style: Optional[List[Tuple[str, str, str]]] = await self.learn_and_store(type="style", num=25)
if not learnt_style: if not learnt_style:
return [] return []
for j in range(1): for _ in range(1):
learnt_grammar: Optional[List[Tuple[str, str, str]]] = await self.learn_and_store(type="grammar", num=10) learnt_grammar: Optional[List[Tuple[str, str, str]]] = await self.learn_and_store(type="grammar", num=10)
if not learnt_grammar: if not learnt_grammar:
return [] return []

View File

@@ -562,9 +562,6 @@ class HeartFChatting:
tuple[bool, str, str]: (是否执行了动作, 思考消息ID, 命令) tuple[bool, str, str]: (是否执行了动作, 思考消息ID, 命令)
""" """
try: try:
action_time = time.time()
action_id = f"{action_time}_{thinking_id}"
# 使用工厂创建动作处理器实例 # 使用工厂创建动作处理器实例
try: try:
action_handler = self.action_manager.create_action( action_handler = self.action_manager.create_action(

View File

@@ -88,10 +88,10 @@ class HeartFCSender:
""" """
if not message.chat_stream: if not message.chat_stream:
logger.error("消息缺少 chat_stream无法发送") logger.error("消息缺少 chat_stream无法发送")
raise "消息缺少 chat_stream无法发送" raise Exception("消息缺少 chat_stream无法发送")
if not message.message_info or not message.message_info.message_id: if not message.message_info or not message.message_info.message_id:
logger.error("消息缺少 message_info 或 message_id无法发送") logger.error("消息缺少 message_info 或 message_id无法发送")
raise "消息缺少 message_info 或 message_id无法发送" raise Exception("消息缺少 message_info 或 message_id无法发送")
chat_id = message.chat_stream.stream_id chat_id = message.chat_stream.stream_id
message_id = message.message_info.message_id message_id = message.message_info.message_id

View File

@@ -100,13 +100,6 @@ class SelfProcessor(BaseProcessor):
tuple: (current_mind, past_mind, prompt) 当前想法、过去的想法列表和使用的prompt tuple: (current_mind, past_mind, prompt) 当前想法、过去的想法列表和使用的prompt
""" """
for observation in observations:
if isinstance(observation, ChattingObservation):
is_group_chat = observation.is_group_chat
chat_target_info = observation.chat_target_info
chat_target_name = "对方" # 私聊默认名称
person_list = observation.person_list
if observations is None: if observations is None:
observations = [] observations = []
for observation in observations: for observation in observations: