refactor(backend): update service layers
- services/ontology.py: update ontology service logic - services/orchestrator.py: update orchestrator service logic - services/user_agent.py: update user agent service logic
This commit is contained in:
@@ -166,20 +166,54 @@ class OrchestratorService:
|
||||
route_json["stage"] = "blocked"
|
||||
route_json["route_reason"] = route_reason
|
||||
elif ontology.clarification_required:
|
||||
outcome = ExecutionOutcome(
|
||||
status=AgentRunStatus.BLOCKED.value,
|
||||
result={
|
||||
"message": ontology.clarification_question or "需要补充更多上下文。",
|
||||
"clarification_required": True,
|
||||
"missing_slots": ontology.missing_slots,
|
||||
"ambiguity": ontology.ambiguity,
|
||||
"parse_strategy": ontology.parse_strategy,
|
||||
"degraded": False,
|
||||
},
|
||||
degraded=False,
|
||||
tool_count=0,
|
||||
failed_tool_count=0,
|
||||
)
|
||||
if selected_agent == AgentName.USER_AGENT.value and ontology.scenario == "expense":
|
||||
clarification_response = self.user_agent_service.respond(
|
||||
UserAgentRequest(
|
||||
run_id=run.run_id,
|
||||
user_id=payload.user_id,
|
||||
message=payload.message or "",
|
||||
ontology=ontology,
|
||||
context_json=context_json,
|
||||
tool_payload={"clarification_required": True},
|
||||
selected_capability_codes=selected_capability_codes,
|
||||
degraded=False,
|
||||
requires_confirmation=requires_confirmation,
|
||||
)
|
||||
)
|
||||
clarification_result = self._build_user_agent_result(
|
||||
clarification_response,
|
||||
degraded=False,
|
||||
)
|
||||
clarification_result.update(
|
||||
{
|
||||
"clarification_required": True,
|
||||
"missing_slots": ontology.missing_slots,
|
||||
"ambiguity": ontology.ambiguity,
|
||||
"parse_strategy": ontology.parse_strategy,
|
||||
}
|
||||
)
|
||||
outcome = ExecutionOutcome(
|
||||
status=AgentRunStatus.BLOCKED.value,
|
||||
result=clarification_result,
|
||||
degraded=False,
|
||||
tool_count=0,
|
||||
failed_tool_count=0,
|
||||
)
|
||||
else:
|
||||
outcome = ExecutionOutcome(
|
||||
status=AgentRunStatus.BLOCKED.value,
|
||||
result={
|
||||
"message": ontology.clarification_question or "需要补充更多上下文。",
|
||||
"clarification_required": True,
|
||||
"missing_slots": ontology.missing_slots,
|
||||
"ambiguity": ontology.ambiguity,
|
||||
"parse_strategy": ontology.parse_strategy,
|
||||
"degraded": False,
|
||||
},
|
||||
degraded=False,
|
||||
tool_count=0,
|
||||
failed_tool_count=0,
|
||||
)
|
||||
route_reason = "clarification_required"
|
||||
route_json["stage"] = "clarification"
|
||||
route_json["route_reason"] = route_reason
|
||||
|
||||
Reference in New Issue
Block a user