perf(methods): 通过移除不必要的 self 参数优化方法签名

在包括 chat、plugin_system、schedule 和 mais4u 在内的多个模块中,消除冗余的实例引用。此次改动将无需访问实例状态的实用函数转换为静态方法,从而提升了内存效率,并使方法依赖关系更加清晰。
This commit is contained in:
雅诺狐
2025-09-20 10:55:06 +08:00
parent 0cc4f5bb27
commit 898208f425
111 changed files with 643 additions and 467 deletions

View File

@@ -492,7 +492,8 @@ class RelationshipManager:
return current_points
def calculate_time_weight(self, point_time: str, current_time: str) -> float:
@staticmethod
def calculate_time_weight(point_time: str, current_time: str) -> float:
"""计算基于时间的权重系数"""
try:
point_timestamp = datetime.strptime(point_time, "%Y-%m-%d %H:%M:%S")
@@ -516,7 +517,8 @@ class RelationshipManager:
logger.error(f"计算时间权重失败: {e}")
return 0.5 # 发生错误时返回中等权重
def tfidf_similarity(self, s1, s2):
@staticmethod
def tfidf_similarity(s1, s2):
"""
使用 TF-IDF 和余弦相似度计算两个句子的相似性。
"""
@@ -551,7 +553,8 @@ class RelationshipManager:
# 返回 s1 和 s2 的相似度
return similarity_matrix[0, 1]
def sequence_similarity(self, s1, s2):
@staticmethod
def sequence_similarity(s1, s2):
"""
使用 SequenceMatcher 计算两个句子的相似性。
"""