记忆系统接入关键词,重新启动自主发言功能
This commit is contained in:
SengokuCola
2025-03-06 14:27:22 +08:00
parent 8bca235ecf
commit eaa711ada7
10 changed files with 520 additions and 112 deletions

View File

@@ -42,7 +42,7 @@ class TopicIdentifier:
print(f"\033[1;32m[主题识别]\033[0m 主题: {topic_list}")
return topic_list if topic_list else None
def identify_topic_snownlp(self, text: str) -> Optional[List[str]]:
def identify_topic_snownlp(self, text: str,num:int=5) -> Optional[List[str]]:
"""使用 SnowNLP 进行主题识别
Args:
@@ -57,7 +57,7 @@ class TopicIdentifier:
try:
s = SnowNLP(text)
# 提取前3个关键词作为主题
keywords = s.keywords(5)
keywords = s.keywords(num)
return keywords if keywords else None
except Exception as e:
print(f"\033[1;31m[错误]\033[0m SnowNLP 处理失败: {str(e)}")