state.py 963 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # agent/state.py
  2. from typing import TypedDict, Literal, Optional, List, Dict, Any
  3. class AgentState(TypedDict):
  4. """LangGraph Agent状态定义"""
  5. # 输入信息
  6. question: str
  7. session_id: Optional[str]
  8. # 分类结果
  9. question_type: Literal["DATABASE", "CHAT", "UNCERTAIN"]
  10. classification_confidence: float
  11. classification_reason: str
  12. classification_method: str # "rule", "llm", "hybrid"
  13. # 数据库查询流程状态
  14. sql: Optional[str]
  15. sql_generation_attempts: int
  16. data_result: Optional[Dict[str, Any]]
  17. summary: Optional[str]
  18. # 聊天响应
  19. chat_response: Optional[str]
  20. # 最终输出
  21. final_response: Dict[str, Any]
  22. # 错误处理
  23. error: Optional[str]
  24. error_code: Optional[int]
  25. # 流程控制
  26. current_step: str
  27. execution_path: List[str]
  28. retry_count: int
  29. max_retries: int
  30. # 调试信息
  31. debug_info: Dict[str, Any]