|
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 追踪功能,可以通过 .env
文件配置:
在 .env
文件中配置:
```bash
LANGCHAIN_TRACING_V2=true
LANGCHAIN_ENDPOINT=https://api.smith.langchain.com
LANGCHAIN_API_KEY=your_langsmith_api_key_here
LANGCHAIN_PROJECT=knowledge-agent
3. 重启服务即可生效
**注意**: 如果没有配置 `.env` 文件或相关环境变量,系统将自动禁用 LangSmith 追踪以避免网络连接错误。
### 数据库配置
在 `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
环境变量服务运行时会输出详细日志,包括: