fix:修复空points问题
This commit is contained in:
@@ -20,9 +20,12 @@ logger = get_logger("processor")
|
||||
def init_prompt():
|
||||
relationship_prompt = """
|
||||
{name_block}
|
||||
你是一个AI,但是你伪装成了一个人类,你不想让别人知道你是一个AI
|
||||
|
||||
你和别人的关系信息是,请从这些信息中提取出你和别人的关系的原文:
|
||||
{relation_prompt}
|
||||
请只从上面这些信息中提取出。
|
||||
|
||||
|
||||
现在是{time_now},你正在上网,和qq群里的网友们聊天,以下是正在进行的聊天内容:
|
||||
{chat_observe_info}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from src.chat.utils.timer_calculator import Timer
|
||||
from src.common.logger_manager import get_logger
|
||||
from src.chat.utils.info_catcher import info_catcher_manager
|
||||
from src.person_info.person_info import person_info_manager
|
||||
from src.chat.utils.utils import process_llm_response
|
||||
|
||||
|
||||
logger = get_logger("normal_chat_response")
|
||||
@@ -57,7 +58,7 @@ class NormalChatGenerator:
|
||||
|
||||
if model_response:
|
||||
logger.debug(f"{global_config.bot.nickname}的原始回复是:{model_response}")
|
||||
model_response = await self.process_llm_response(model_response)
|
||||
model_response = process_llm_response(model_response)
|
||||
|
||||
return model_response
|
||||
else:
|
||||
|
||||
@@ -24,10 +24,10 @@ class ImpressionUpdateTask(AsyncTask):
|
||||
try:
|
||||
# 获取最近的消息
|
||||
current_time = int(time.time())
|
||||
start_time = current_time - 360000 # 1小时前
|
||||
start_time = current_time - 600 # 1小时前
|
||||
|
||||
# 获取所有消息
|
||||
messages = get_raw_msg_by_timestamp(timestamp_start=start_time, timestamp_end=current_time, limit=200)
|
||||
messages = get_raw_msg_by_timestamp(timestamp_start=start_time, timestamp_end=current_time, limit=300)
|
||||
|
||||
if not messages:
|
||||
logger.info("没有找到需要处理的消息")
|
||||
@@ -66,11 +66,11 @@ class ImpressionUpdateTask(AsyncTask):
|
||||
|
||||
# 获取第一条bot消息前15条消息
|
||||
first_bot_index = sorted_messages.index(first_bot_msg)
|
||||
start_index = max(0, first_bot_index - 15)
|
||||
start_index = max(0, first_bot_index - 25)
|
||||
|
||||
# 获取最后一条bot消息后15条消息
|
||||
last_bot_index = sorted_messages.index(last_bot_msg)
|
||||
end_index = min(len(sorted_messages), last_bot_index + 16)
|
||||
end_index = min(len(sorted_messages), last_bot_index + 26)
|
||||
|
||||
# 获取相关消息
|
||||
relevant_messages = sorted_messages[start_index:end_index]
|
||||
|
||||
@@ -121,9 +121,15 @@ class RelationshipManager:
|
||||
person_name = await person_info_manager.get_value(person_id, "person_name")
|
||||
impression = await person_info_manager.get_value(person_id, "impression")
|
||||
interaction = await person_info_manager.get_value(person_id, "interaction")
|
||||
points = await person_info_manager.get_value(person_id, "points")
|
||||
points = await person_info_manager.get_value(person_id, "points") or []
|
||||
|
||||
random_points = random.sample(points, min(3, len(points)))
|
||||
if isinstance(points, str):
|
||||
try:
|
||||
points = ast.literal_eval(points)
|
||||
except (SyntaxError, ValueError):
|
||||
points = []
|
||||
|
||||
random_points = random.sample(points, min(3, len(points))) if points else []
|
||||
|
||||
nickname_str = await person_info_manager.get_value(person_id, "nickname")
|
||||
platform = await person_info_manager.get_value(person_id, "platform")
|
||||
@@ -138,6 +144,9 @@ class RelationshipManager:
|
||||
|
||||
if random_points:
|
||||
for point in random_points:
|
||||
# print(f"point: {point}")
|
||||
# print(f"point[2]: {point[2]}")
|
||||
# print(f"point[0]: {point[0]}")
|
||||
point_str = f"时间:{point[2]}。内容:{point[0]}"
|
||||
relation_prompt += f"你记得{person_name}最近的点是:{point_str}。"
|
||||
|
||||
@@ -223,7 +232,7 @@ class RelationshipManager:
|
||||
)
|
||||
|
||||
for original_name, mapped_name in name_mapping.items():
|
||||
print(f"original_name: {original_name}, mapped_name: {mapped_name}")
|
||||
# print(f"original_name: {original_name}, mapped_name: {mapped_name}")
|
||||
readable_messages = readable_messages.replace(f"{original_name}", f"{mapped_name}")
|
||||
|
||||
prompt = f"""
|
||||
@@ -502,8 +511,8 @@ class RelationshipManager:
|
||||
keep_indices = set()
|
||||
for idx in target_indices:
|
||||
# 获取前后5条消息的索引
|
||||
start_idx = max(0, idx - 10)
|
||||
end_idx = min(len(messages), idx + 11)
|
||||
start_idx = max(0, idx - 5)
|
||||
end_idx = min(len(messages), idx + 6)
|
||||
keep_indices.update(range(start_idx, end_idx))
|
||||
|
||||
print(keep_indices)
|
||||
|
||||
Reference in New Issue
Block a user