better:回复现在依照条数和长度而不是时间引用

This commit is contained in:
SengokuCola
2025-04-04 00:30:27 +08:00
parent e717bc34b0
commit a92aa35e72
7 changed files with 177 additions and 56 deletions

View File

@@ -9,7 +9,7 @@ from .message import MessageSending, MessageThinking, MessageSet
from ..storage.storage import MessageStorage
from ..config.config import global_config
from .utils import truncate_message, calculate_typing_time
from .utils import truncate_message, calculate_typing_time, count_messages_between
from src.common.logger import LogConfig, SENDER_STYLE_CONFIG
@@ -85,7 +85,7 @@ class MessageContainer:
self.max_size = max_size
self.messages = []
self.last_send_time = 0
self.thinking_timeout = 10 # 思考等待超时时间(秒)
self.thinking_timeout = 20 # 思考等待超时时间(秒)
def get_timeout_messages(self) -> List[MessageSending]:
"""获取所有超时的Message_Sending对象思考时间超过30秒按thinking_start_time排序"""
@@ -172,6 +172,7 @@ class MessageManager:
message_earliest = container.get_earliest_message()
if isinstance(message_earliest, MessageThinking):
"""取得了思考消息"""
message_earliest.update_thinking_time()
thinking_time = message_earliest.thinking_time
# print(thinking_time)
@@ -187,14 +188,18 @@ class MessageManager:
container.remove_message(message_earliest)
else:
# print(message_earliest.is_head)
# print(message_earliest.update_thinking_time())
# print(message_earliest.is_private_message())
"""取得了发送消息"""
thinking_time = message_earliest.update_thinking_time()
print(thinking_time)
thinking_start_time = message_earliest.thinking_start_time
now_time = time.time()
thinking_messages_count, thinking_messages_length = count_messages_between(start_time=thinking_start_time, end_time=now_time, stream_id=message_earliest.chat_stream.stream_id)
# print(thinking_time)
# print(thinking_messages_count)
# print(thinking_messages_length)
if (
message_earliest.is_head
and message_earliest.update_thinking_time() > 18
and (thinking_messages_count > 4 or thinking_messages_length > 250)
and not message_earliest.is_private_message() # 避免在私聊时插入reply
):
logger.debug(f"设置回复消息{message_earliest.processed_plain_text}")
@@ -216,12 +221,16 @@ class MessageManager:
continue
try:
# print(msg.is_head)
print(msg.update_thinking_time())
# print(msg.is_private_message())
thinking_time = msg.update_thinking_time()
thinking_start_time = msg.thinking_start_time
now_time = time.time()
thinking_messages_count, thinking_messages_length = count_messages_between(start_time=thinking_start_time, end_time=now_time, stream_id=msg.chat_stream.stream_id)
# print(thinking_time)
# print(thinking_messages_count)
# print(thinking_messages_length)
if (
msg.is_head
and msg.update_thinking_time() > 18
and (thinking_messages_count > 4 or thinking_messages_length > 250)
and not msg.is_private_message() # 避免在私聊时插入reply
):
logger.debug(f"设置回复消息{msg.processed_plain_text}")