feat: v4 multimodal chat input, multi-format support, and annotation detection

- Replace st.chat_input with st-multimodal-chatinput (Ctrl+V paste, drag-drop, file button)
- Extract _process_uploaded_file() shared handler (eliminates ~70 duplicated lines)
- Add XLSX (openpyxl), XLS (xlrd), DOC (olefile) parsers to file_parser.py
- Add backend/annotation_detector.py: circle detection (HoughCircles) + arrow detection (HoughLinesP clustering) + OCR correlation + LLM context formatting
- Add annotation_result field to AgentState with session persistence
- Wire annotation detection into process_input and _format_ocr_context
- Add 11 new tests: 7 annotation detector + 4 multi-format parser
- Update all docs: CLAUDE.md, README.md, CODE_GUIDE.md, ROADMAP.md
This commit is contained in:
2026-05-20 23:43:16 +08:00
parent c9f003e1b7
commit 9bb011e429
16 changed files with 1257 additions and 164 deletions
+14 -4
View File
@@ -8,6 +8,10 @@
- **自动验证**:每次生成或修改后都会验证 JRXML
- **自动修正**:如果验证失败,代理会分析错误并自动修正(最多 3 次)
- **模板检索**:使用 Chroma 向量数据库检索相关的 JRXML 示例以获得更好的生成效果
- **文件上传**:支持图片(OCR识别)、PDF、Word、Excel、文本文件等
- **聊天粘贴/拖拽**:支持直接在对话框中 Ctrl+V 粘贴或拖拽文件(图片/PDF/Excel/Word
- **单据OCR识别**:上传报表单据图片后自动提取所有字段(4策略优先级 + 置信度评分)
- **批注检测**:识别手写单据上的圈选和箭头标记,自动定位用户要修改的字段
- **下载**:导出已验证的、可供 JasperReports 使用的 JRXML 文件
## 架构
@@ -105,10 +109,10 @@ pytest tests/ -v
```
jrxml-agent/
app.py Streamlit 聊天界面
app.py Streamlit 聊天界面(多模态输入)
agent/
state.py AgentState 定义
nodes.py 图节点(generate, validate, modify 等)
state.py AgentState 定义26 字段)
nodes.py 图节点(generate, validate, modify 等15 节点
graph.py LangGraph 状态机
backend/
llm.py LLM 工厂(Anthropic SDK / OpenAI / Ollama
@@ -117,8 +121,10 @@ jrxml-agent/
validation.py 验证服务客户端
rag_adapter.py RAG 语义搜索适配器
error_kb.py 错误自增长知识库
file_parser.py 文件解析器(PDF/DOCX/图片
file_parser.py 文件解析器(PDF/DOCX/XLSX/XLS/DOC/图片/文本
layout_analyzer.py A4 模板布局分析
ocr_extractor.py OCR 字段精确提取(4 策略 + 置信度)
annotation_detector.py 批注检测(圈选 + 箭头 + OCR 关联)
session.py 会话持久化 CRUD
prompts/
loader.py Prompt 加载器(热重载)
@@ -137,6 +143,10 @@ jrxml-agent/
tests/
test_validation.py 验证服务测试
test_agent.py 代理集成测试
test_e2e_ocr.py OCR 端到端测试
test_ocr_extraction.py OCR 字段提取单元测试
test_annotation_detector.py 批注检测测试
test_file_parser_formats.py 多格式解析测试
requirements.txt
.env.example
README.md