fixruad
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import difflib
|
||||
import random
|
||||
|
||||
|
||||
def ji_suan_xiang_si_du(wen_ben_yi: str, wen_ben_er: str) -> float:
|
||||
"""
|
||||
计算两个文本字符串的相似度。
|
||||
@@ -17,6 +18,7 @@ def ji_suan_xiang_si_du(wen_ben_yi: str, wen_ben_er: str) -> float:
|
||||
xiang_si_bi_lv = xu_lie_pi_pei_qi.ratio()
|
||||
return xiang_si_bi_lv
|
||||
|
||||
|
||||
def ji_suan_ti_huan_gai_lv(xiang_si_du: float) -> float:
|
||||
"""
|
||||
根据相似度计算替换的概率。
|
||||
@@ -40,6 +42,7 @@ def ji_suan_ti_huan_gai_lv(xiang_si_du: float) -> float:
|
||||
gai_lv = xiang_si_du + 0.1
|
||||
return min(1.0, max(0.0, gai_lv)) # 确保概率在 0 和 1 之间
|
||||
|
||||
|
||||
# 获取用户输入
|
||||
shu_ru_yi = "豆豆刚刚回复了我的问候 现在可以等待对方的回应 不需要再主动发言 目前情绪满足 不需要使用工具"
|
||||
|
||||
|
||||
@@ -417,6 +417,7 @@ class BotConfig:
|
||||
config.model_normal_probability = response_config.get(
|
||||
"model_normal_probability", config.model_normal_probability
|
||||
)
|
||||
|
||||
def heartflow(parent: dict):
|
||||
heartflow_config = parent["heartflow"]
|
||||
config.sub_heart_flow_stop_time = heartflow_config.get(
|
||||
|
||||
@@ -160,8 +160,6 @@ class ChattingObservation(Observation):
|
||||
|
||||
# print(f"self.11111person_list: {self.person_list}")
|
||||
|
||||
|
||||
|
||||
logger.trace(
|
||||
f"Chat {self.chat_id} - 压缩早期记忆:{self.mid_memory_info}\n现在聊天内容:{self.talking_message_str}"
|
||||
)
|
||||
|
||||
@@ -16,7 +16,6 @@ import difflib
|
||||
from src.plugins.person_info.relationship_manager import relationship_manager
|
||||
|
||||
|
||||
|
||||
logger = get_logger("sub_heartflow")
|
||||
|
||||
|
||||
@@ -60,6 +59,7 @@ def calculate_similarity(text_a: str, text_b: str) -> float:
|
||||
matcher = difflib.SequenceMatcher(None, text_a, text_b)
|
||||
return matcher.ratio()
|
||||
|
||||
|
||||
def calculate_replacement_probability(similarity: float) -> float:
|
||||
"""
|
||||
根据相似度计算替换的概率。
|
||||
@@ -139,7 +139,6 @@ class SubMind:
|
||||
# 获取个性化信息
|
||||
individuality = Individuality.get_instance()
|
||||
|
||||
|
||||
relation_prompt = ""
|
||||
print(f"person_list: {person_list}")
|
||||
for person in person_list:
|
||||
@@ -320,7 +319,9 @@ class SubMind:
|
||||
logger.debug(f"{self.log_prefix} 想法完全重复 (相似度 1.0),执行特殊处理...")
|
||||
# 随机截取大约一半内容
|
||||
if len(new_content) > 1: # 避免内容过短无法截取
|
||||
split_point = max(1, len(new_content) // 2 + random.randint(-len(new_content)//4, len(new_content)//4))
|
||||
split_point = max(
|
||||
1, len(new_content) // 2 + random.randint(-len(new_content) // 4, len(new_content) // 4)
|
||||
)
|
||||
truncated_content = new_content[:split_point]
|
||||
else:
|
||||
truncated_content = new_content # 如果只有一个字符或者为空,就不截取了
|
||||
|
||||
@@ -348,7 +348,10 @@ async def build_readable_messages(
|
||||
messages_before_mark, replace_bot_name, merge_messages, timestamp_mode, truncate
|
||||
)
|
||||
formatted_after, _ = await _build_readable_messages_internal(
|
||||
messages_after_mark, replace_bot_name, merge_messages, timestamp_mode,
|
||||
messages_after_mark,
|
||||
replace_bot_name,
|
||||
merge_messages,
|
||||
timestamp_mode,
|
||||
)
|
||||
|
||||
readable_read_mark = translate_timestamp_to_human_readable(read_mark, mode=timestamp_mode)
|
||||
|
||||
Reference in New Issue
Block a user