perf: switch to single-stage routing and low-latency defaults
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled

This commit is contained in:
2026-03-03 14:36:33 +08:00
parent c23b1bb203
commit 77391daf77
4 changed files with 70 additions and 18 deletions

View File

@@ -2,8 +2,7 @@ from __future__ import annotations
from typing import Any
from .agents import AfterSalesAgent, PreSalesAgent, QuoteAgent, RiskAgent, RouterAgent
from .config import FAST_ROUTE_ENABLED
from .agents import AfterSalesAgent, PreSalesAgent, QuoteAgent, RiskAgent
from .image_quote_analyzer import analyze_image_for_quote
from .models import Decision
from .state_machine import evolve_after_sales_state, migrate_state_schema
@@ -12,7 +11,6 @@ from .store import ConversationStore
class Orchestrator:
def __init__(self) -> None:
self.router = RouterAgent()
self.pre_sales = PreSalesAgent()
self.quote = QuoteAgent()
self.after_sales = AfterSalesAgent()
@@ -20,9 +18,7 @@ class Orchestrator:
self.store = ConversationStore()
@staticmethod
def _fast_route(context: dict[str, Any]) -> tuple[str, str] | None:
if not FAST_ROUTE_ENABLED:
return None
def _single_stage_route(context: dict[str, Any]) -> tuple[str, str]:
msg = str(context.get("msg", "") or "")
lower = msg.lower()
if bool(context.get("auto_quote_trigger")):
@@ -34,7 +30,7 @@ class Orchestrator:
return "quote", "fast:pending_image_and_pricing"
if any(k in lower for k in ("退款", "退钱", "不满意", "重做", "售后", "返工", "重发")):
return "after_sales", "fast:after_sales_keyword"
return None
return "pre_sales", "single_stage:default_pre_sales"
async def decide(self, context: dict[str, Any]) -> tuple[str, Decision, dict[str, Any]]:
customer_key = context["customer_key"]
@@ -54,11 +50,7 @@ class Orchestrator:
"order_status": order_status,
}
fast = self._fast_route(merged_ctx)
if fast is not None:
route, route_reason = fast
else:
route, route_reason = await self.router.route(merged_ctx)
route, route_reason = self._single_stage_route(merged_ctx)
if route == "quote":
latest_image_url = str(context.get("latest_image_url", "") or "").strip()