feat: 重构知识库系统,移除Hermes集成,增强RAG和同步功能
主要变更: - 移除Hermes智能体及相关回调服务 - 新增知识库RAG、同步、调度、规范化和索引任务服务 - 重构orchestrator服务,增强运行时聊天功能 - 更新前端聊天、政策制度、设置等页面样式和逻辑 - 更新expense_claims和document_intelligence服务 - 删除llm_wiki相关服务和测试文件 - 更新docker-compose配置和启动脚本
This commit is contained in:
@@ -243,6 +243,7 @@ STATUS_KEYWORDS = {
|
||||
|
||||
PRIVILEGED_ROLE_CODES = {"manager", "finance", "approver", "executive"}
|
||||
CONTEXTUAL_SCENARIOS = {"expense", "accounts_receivable", "accounts_payable", "knowledge"}
|
||||
KNOWLEDGE_INTENTS = {"query", "explain", "compare"}
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -356,7 +357,7 @@ class SemanticOntologyService:
|
||||
rule_scenario = inferred_scenario
|
||||
scenario_score = 0.18
|
||||
|
||||
if self._looks_like_expense_narrative(
|
||||
if session_scenario != "knowledge" and self._looks_like_expense_narrative(
|
||||
compact_query,
|
||||
scenario=rule_scenario,
|
||||
entities=entities,
|
||||
@@ -371,7 +372,7 @@ class SemanticOntologyService:
|
||||
entities=entities,
|
||||
time_range=time_range,
|
||||
)
|
||||
if self._should_inherit_expense_draft(
|
||||
if session_scenario != "knowledge" and self._should_inherit_expense_draft(
|
||||
compact_query,
|
||||
scenario=rule_scenario,
|
||||
entities=entities,
|
||||
@@ -384,17 +385,19 @@ class SemanticOntologyService:
|
||||
intent_score = max(intent_score, 0.18)
|
||||
metrics = self._extract_metrics(compact_query)
|
||||
constraints = self._extract_constraints(compact_query, entities)
|
||||
model_parse = self._parse_with_model(
|
||||
payload=payload,
|
||||
query=query,
|
||||
compact_query=compact_query,
|
||||
fallback_scenario=rule_scenario,
|
||||
fallback_intent=rule_intent,
|
||||
entities=entities,
|
||||
time_range=time_range,
|
||||
metrics=metrics,
|
||||
constraints=constraints,
|
||||
)
|
||||
model_parse = None
|
||||
if session_scenario != "knowledge":
|
||||
model_parse = self._parse_with_model(
|
||||
payload=payload,
|
||||
query=query,
|
||||
compact_query=compact_query,
|
||||
fallback_scenario=rule_scenario,
|
||||
fallback_intent=rule_intent,
|
||||
entities=entities,
|
||||
time_range=time_range,
|
||||
metrics=metrics,
|
||||
constraints=constraints,
|
||||
)
|
||||
scenario = self._resolve_scenario(rule_scenario, model_parse)
|
||||
if session_scenario == "knowledge":
|
||||
scenario = "knowledge"
|
||||
@@ -968,6 +971,12 @@ class SemanticOntologyService:
|
||||
model_parse: LlmOntologyParseResult | None,
|
||||
) -> str:
|
||||
candidate = model_parse.intent if model_parse is not None else fallback_intent
|
||||
if scenario == "knowledge":
|
||||
if candidate in KNOWLEDGE_INTENTS:
|
||||
return candidate
|
||||
if fallback_intent in KNOWLEDGE_INTENTS:
|
||||
return fallback_intent
|
||||
return "query"
|
||||
if candidate == "query" and scenario == "expense":
|
||||
if self._is_generic_expense_prompt(compact_query) or fallback_intent == "draft":
|
||||
return "draft"
|
||||
|
||||
Reference in New Issue
Block a user