|
1 week ago | |
---|---|---|
indentify | 1 week ago | |
prompt | 1 week ago | |
structure | 1 week ago | |
utils | 1 week ago | |
.DS_Store | 1 week ago | |
.env | 1 week ago | |
.gitignore | 1 week ago | |
README.md | 1 week ago | |
agent.py | 1 week ago | |
agent_tools.py | 1 week ago | |
gemini.py | 1 week ago | |
requirements.txt | 1 week ago | |
start_service.sh | 1 week ago |
基于 FastAPI + LangGraph 的智能内容识别和结构化处理服务。
pip install -r requirements.txt
./start_service.sh
python3 agent.py
uvicorn agent:app --host 0.0.0.0 --port 8080 --reload
同步解析内容处理
请求体:
{
"requestId": "your_request_id"
}
响应:
{
"requestId": "your_request_id",
"processed": 5,
"success": 4,
"details": [
{
"index": 1,
"dbInserted": true,
"identifyError": null,
"status": "success"
}
]
}
异步解析内容处理(后台任务)
请求体:
{
"requestId": "your_request_id"
}
响应:
{
"requestId": "your_request_id",
"status": "processing",
"message": "任务已提交到后台处理"
}
健康检查接口
响应:
{
"status": "healthy",
"timestamp": 1703123456.789
}
GEMINI_API_KEY
: Gemini API 密钥(必需)为了避免网络连接错误,系统会自动禁用 LangSmith 追踪。如果需要启用,可以设置以下环境变量:
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
export LANGCHAIN_API_KEY="your_langsmith_api_key"
在 utils/mysql_db.py
中配置数据库连接信息。
knowledge-agent/
├── agent.py # FastAPI + LangGraph 主服务文件
├── agent_tools.py # 核心工具类
├── gemini.py # Gemini API 处理器
├── indentify/ # 内容识别模块
│ ├── image_identifier.py # 图像识别
│ ├── video_identifier.py # 视频识别
│ └── indentify.py # 识别主逻辑
├── structure/ # 结构化处理模块
│ └── structure_processor.py
├── utils/ # 工具模块
│ ├── mysql_db.py # 数据库操作
│ ├── logging_config.py # 日志配置
│ └── file.py # 文件操作
├── prompt/ # 提示词模板
├── requirements.txt # 依赖包列表
└── start_service.sh # 启动脚本
GEMINI_API_KEY
环境变量服务运行时会输出详细日志,包括: