feat:客户agent以及记忆模块优化
This commit is contained in:
+1
-12
@@ -14,8 +14,7 @@ class FinalConfidenceRankTool:
|
||||
"semantic": 0.30,
|
||||
"timeliness": 0.20,
|
||||
"accuracy": 0.20,
|
||||
"base": 0.25,
|
||||
"conflict": 0.05,
|
||||
"base": 0.30,
|
||||
}
|
||||
INVALID_STATUSES = frozenset({"expired", "rejected", "archived"})
|
||||
|
||||
@@ -39,13 +38,11 @@ class FinalConfidenceRankTool:
|
||||
timeliness = self._calc_timeliness(unit.get("age_days", 0))
|
||||
accuracy = self._bounded(unit.get("historical_accuracy", 0.5), 0.5)
|
||||
base = self._bounded(unit.get("confidence", 0.5), 0.5)
|
||||
conflict_penalty = min(self._non_negative_int(unit.get("conflict_count", 0)), 5) * 0.1
|
||||
final_score = (
|
||||
self.WEIGHTS["semantic"] * semantic
|
||||
+ self.WEIGHTS["timeliness"] * timeliness
|
||||
+ self.WEIGHTS["accuracy"] * accuracy
|
||||
+ self.WEIGHTS["base"] * base
|
||||
- self.WEIGHTS["conflict"] * conflict_penalty
|
||||
)
|
||||
unit["final_score"] = max(0.0, min(1.0, final_score))
|
||||
ranked.append(unit)
|
||||
@@ -78,14 +75,6 @@ class FinalConfidenceRankTool:
|
||||
return default
|
||||
return max(0.0, min(1.0, value))
|
||||
|
||||
@staticmethod
|
||||
def _non_negative_int(value: Any) -> int:
|
||||
"""将冲突次数转换为非负整数。"""
|
||||
try:
|
||||
return max(0, int(value))
|
||||
except (TypeError, ValueError):
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def _calc_timeliness(age_days: Any) -> float:
|
||||
"""按每年 20% 计算平滑时效分,最低保留 0.8。"""
|
||||
|
||||
Reference in New Issue
Block a user