Files
agent_jrxml/agent/state.py
T

65 lines
2.2 KiB
Python
Raw Normal View History

"""LangGraph JRXML 生成代理工作流的状态定义。"""
from typing import TypedDict, List
class AgentState(TypedDict, total=False):
# 核心工作流字段
conversation_history: List[dict]
current_jrxml: str
user_input: str
status: str
error_msg: str
natural_explanation: str
retry_count: int
user_modification_request: str
final_jrxml: str
stage: str
retrieved_context: str
# 需求1:智能上下文压缩
full_conversation_history: List[dict]
compressed_history: str
current_token_count: int
# 需求2:多会话持久化
session_id: str
session_name: str
created_at: str
updated_at: str
# 需求3:意图识别
intent: str
history_states: List[dict]
# 需求4:JRXML 版本历史(用于下载历史版本)
jrxml_versions: List[dict]
# 需求5:错误自增长(记录修正前的状态,供 validate 节点判断是否入知识库)
last_error_case: dict
# 需求6:失败上下文传递 — 重试耗尽后暂存失败信息,下次用户输入时自动注入
pending_failure_context: dict
# 需求7:OCR 单据字段精确提取结果
ocr_extraction_result: dict
uploaded_file_path: str
# 需求8:图片批注检测(圈选/箭头标记)
annotation_result: dict
# 需求9:分层精确生成
layout_schema: dict # extract_layout_schema() 输出,列+区域结构
ocr_elements: list # OCR 原始行数据(用于阶段二坐标采样)
# 需求10:多租户知识库
kb_id: str # 当前会话绑定的知识库 ID
kb_fields: list # KB 提取的字段定义 [{name, description, type, required}]
kb_field_mapping: dict # OCR 字段 → KB 字段映射 {"工单号": "billNo", ...}
uploaded_template_jrxml: str # 对话中上传的 JRXML 模板原文
uploaded_template_params: list # 解析出的参数 [{name, type}]
kb_template_jrxml: str # 从 KB 检索到的模板 JRXML
kb_template_name: str # 检索到的模板名称
datasource_mode: str # "parameter" 或 "jdbc"
db_config: dict # JDBC 连接配置