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
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:
@@ -12,8 +12,8 @@ OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "").strip()
|
||||
OPENAI_BASE_URL = os.getenv("OPENAI_BASE_URL", "https://ark.cn-beijing.volces.com/api/v3").strip()
|
||||
OPENAI_MODEL_NAME = os.getenv("OPENAI_MODEL_NAME", "doubao-seed-2-0-pro-260215").strip()
|
||||
|
||||
MESSAGE_DEBOUNCE_SECONDS = float(os.getenv("MESSAGE_DEBOUNCE_SECONDS", "0.8"))
|
||||
IMAGE_MESSAGE_DEBOUNCE_SECONDS = float(os.getenv("IMAGE_MESSAGE_DEBOUNCE_SECONDS", "1.2"))
|
||||
MESSAGE_DEBOUNCE_SECONDS = float(os.getenv("MESSAGE_DEBOUNCE_SECONDS", "0.2"))
|
||||
IMAGE_MESSAGE_DEBOUNCE_SECONDS = float(os.getenv("IMAGE_MESSAGE_DEBOUNCE_SECONDS", "0.4"))
|
||||
AUTO_QUOTE_WAIT_SECONDS = int(os.getenv("AUTO_QUOTE_WAIT_SECONDS", "18"))
|
||||
AGENT_MAX_ITERS = int(os.getenv("AGENT_MAX_ITERS", "1"))
|
||||
FAST_ROUTE_ENABLED = os.getenv("FAST_ROUTE_ENABLED", "1").strip() in {"1", "true", "True", "yes", "on"}
|
||||
@@ -47,4 +47,4 @@ AUTO_DRAW_TIMEOUT_SECONDS = int(os.getenv("AUTO_DRAW_TIMEOUT_SECONDS", "25"))
|
||||
|
||||
# 并发与超时
|
||||
MAX_CONCURRENT_TURNS = int(os.getenv("MAX_CONCURRENT_TURNS", "4"))
|
||||
DECISION_TIMEOUT_SECONDS = int(os.getenv("DECISION_TIMEOUT_SECONDS", "60"))
|
||||
DECISION_TIMEOUT_SECONDS = int(os.getenv("DECISION_TIMEOUT_SECONDS", "8"))
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user