Intelligent Cabin Agent
Quick Start
- Create and activate the Python 3.11 virtual environment:
uv venv .venv --python 3.11
source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Start the service:
.venv/bin/uvicorn app.main:app --host 127.0.0.1 --port 8000
- Open the API docs:
http://127.0.0.1:8000/docs
Demo UI:
http://127.0.0.1:8000/demo
Architecture and flow review:
solution_review.md
The demo console supports:
- local browser session history restore
- runtime matcher/classifier/session backend switching
- matcher routing debug panel with Top-K candidates
- local
rewrite -> keyword/classifier/retrieval -> fusiondecision trace - direct display of classifier backend / raw label / fallback reason / raw candidate payload
- workflow JSON visualization
Core APIs
POST /api/v1/agent/chatPOST /api/v1/agent/fill-slotsGET /health
Current Scope
- Configurable session backend: memory / Redis
- Config-driven intent registry
- Router layer with pluggable matcher / extractor
- Rule-based fast-path intent routing
- Basic slot extraction
- Plugin registry with mock handlers
- Workflow response payloads
Runtime Config
AGENT_SESSION_BACKEND=memory|redisAGENT_REDIS_URL=redis://127.0.0.1:6379/0AGENT_REDIS_KEY_PREFIX=agent:sessionAGENT_SESSION_TTL_SECONDS=86400AGENT_MATCHER_PIPELINE=keywordAGENT_SLOT_EXTRACTOR_BACKEND=heuristicAGENT_CLASSIFIER_BACKEND=mockAGENT_CLASSIFIER_THRESHOLD=1.2AGENT_CLASSIFIER_BERT_THRESHOLD=0.0AGENT_CLASSIFIER_MODEL_PATH=/path/to/modelAGENT_CLASSIFIER_LABEL_MAP_PATH=/path/to/label_map.jsonAGENT_CLASSIFIER_REMOTE_URL=http://127.0.0.1:9000/classifyAGENT_CLASSIFIER_REMOTE_TIMEOUT_SECONDS=3.0AGENT_LOCAL_EXECUTE_THRESHOLD=1.65AGENT_LOCAL_ROUTE_TO_CLOUD_THRESHOLD=0.75AGENT_LOCAL_CLARIFY_MARGIN_THRESHOLD=0.12AGENT_PLANNER_BACKEND=heuristic|dashscopeAGENT_PLANNER_BASE_URL=https://your-base-url/v1AGENT_PLANNER_API_KEY=your-api-keyAGENT_PLANNER_MODEL_NAME=qwen3.5-plusAGENT_PLANNER_TIMEOUT_SECONDS=6.0
Matcher pipeline examples:
AGENT_MATCHER_PIPELINE=keywordAGENT_MATCHER_PIPELINE=keyword,classifier,retrievalAGENT_MATCHER_PIPELINE=keyword,retrievalAGENT_MATCHER_PIPELINE=classifierAGENT_MATCHER_PIPELINE=retrieval
Classifier backend examples:
AGENT_CLASSIFIER_BACKEND=mockAGENT_CLASSIFIER_BACKEND=bertAGENT_CLASSIFIER_BACKEND=remoteAGENT_CLASSIFIER_TOP_K=3
For local BERT models:
- install optional runtime deps such as
transformersand a backend liketorch - point
AGENT_CLASSIFIER_MODEL_PATHto the local model directory - if the model outputs labels like
LABEL_0, provideAGENT_CLASSIFIER_LABEL_MAP_PATH - use
AGENT_CLASSIFIER_BERT_THRESHOLDinstead of the mock threshold
Example label map:
{
"LABEL_0": "cs_query_order",
"LABEL_1": "cs_cancel_order",
"LABEL_2": "cabin_play_music"
}
Remote classifier expected request payload:
{
"text": "我的订单现在什么情况 A808001",
"top_k": 3,
"labels": ["cs_query_order", "cs_cancel_order", "cabin_play_music"]
}
Remote classifier response payload:
{
"intent_id": "cs_query_order",
"label": "LABEL_0",
"score": 0.982,
"model_name": "bert-remote-v1",
"candidates": [
{"label": "LABEL_0", "intent_id": "cs_query_order", "score": 0.982},
{"label": "LABEL_1", "intent_id": "cs_cancel_order", "score": 0.011},
{"label": "LABEL_7", "intent_id": "cs_query_logistics", "score": 0.007}
]
}
When bert or remote is unavailable or below threshold, the classifier falls back to mock, and the demo debug panel shows both the attempted backend and the fallback reason.
Planner notes:
- keep the planner key in environment variables, not in source code or front-end code
- the planner uses
POST {base_url}/chat/completions - for DashScope OpenAI-compatible endpoints, use the compatible
v1base URL and setAGENT_PLANNER_BACKEND=dashscope - when cloud planning is unavailable, the service falls back to a local heuristic planner for multi-command splitting
Next Steps
- Replace rule router with classifier + retrieval + LLM
- Connect real business plugins
- Add automated tests