# qlinpython **Repository Path**: superhigher/qlinpython ## Basic Information - **Project Name**: qlinpython - **Description**: ai智能体后台处理(适配麒麟操作系统) - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-20 - **Last Updated**: 2026-05-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 邮件智能分派系统 - Python后端 基于 **LangChain + LlamaIndex** 的智能邮件分派后端服务。 ## 技术栈 | 组件 | 技术 | |------|------| | Web框架 | FastAPI | | RAG框架 | LangChain LCEL | | 索引检索 | LlamaIndex | | Embedding | BAAI/bge-large-zh-v1.5 | | LLM | DeepSeek / Qwen / GPT | | 数据库 | MySQL | ## 项目结构 ``` qlinpython/ ├── app/ │ ├── main.py # FastAPI入口 │ ├── api/ # API路由 │ │ ├── email.py # 邮件分派接口 │ │ └── knowledge.py # 知识库管理接口 │ ├── core/ # 核心配置 │ │ ├── config.py # 配置管理 │ │ ├── database.py # 数据库连接 │ │ ├── embeddings.py # LangChain Embeddings │ │ └── llm.py # LangChain LLM │ ├── models/ # 数据模型 │ │ ├── db_models.py # SQLAlchemy模型 │ │ └── schema.py # Pydantic模型 │ └── services/ # 业务逻辑 │ ├── vector_store.py # LlamaIndex向量存储 │ ├── rag_chain.py # LangChain RAG Chain │ ├── dispatch.py # 分派服务 │ └── feedback.py # 反馈服务 ├── init_db.sql # 数据库初始化 ├── requirements.txt └── README.md ``` ## 快速开始 ### 1. 安装依赖 ```bash cd qlinpython pip install -r requirements.txt ``` ### 2. 配置环境 ```bash cp .env.example .env # 编辑 .env 填入数据库和API密钥 ``` ### 3. 初始化数据库 ```bash mysql -u root -p < init_db.sql ``` ### 4. 启动服务 ```bash uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 ``` ### 5. 访问API - Swagger文档: http://localhost:8000/docs ## API接口 ### 邮件分派 ```bash # 智能分派 POST /api/email/dispatch { "email_title": "数据库故障", "email_content": "数据库连接池超时..." } # 确认分派 POST /api/email/confirm { "record_id": 1, "actual_person": "张三", "actual_urgency": "urgent", "is_modified": false } # 驳回分派 POST /api/email/reject { "record_id": 1, "reject_reason": "应该分派给李四" } ``` ### 知识库管理 ```bash # 案例 GET/POST /api/knowledge/cases GET/DELETE /api/knowledge/cases/{id} # 人员 GET/POST /api/knowledge/persons GET/PUT/DELETE /api/knowledge/persons/{id} # 统计 GET /api/knowledge/statistics GET /api/knowledge/records ``` ## RAG 流程 ``` 新邮件 ↓ LangChain Embeddings → 向量 ↓ LlamaIndex 检索 ← 历史案例 + 人员领域 ↓ 构建上下文 (cases_context + persons_context) ↓ LangChain LCEL Chain → LLM ↓ 推荐结果 (负责人 + 级别 + 理由) ``` ## 前端对接 ```typescript const response = await fetch('http://localhost:8000/api/email/dispatch', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email_title: '邮件标题', email_content: '邮件内容' }) }); const result = await response.json(); console.log(result); ```