|
|
@@ -1,156 +1,77 @@
|
|
|
-### LQAgentPlatform
|
|
|
+# LQAgentPlatform
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- ### LQAgentPlatform 智能体应用服务
|
|
|
- - 环境安装
|
|
|
- - pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
|
|
- - 后端启动服务
|
|
|
- - cd LQAgentPlatform
|
|
|
- - uvicorn server.app:app --port=8001 --host=0.0.0.0
|
|
|
- - gunicorn -c gunicorn_config.py server.app:app 多进程启动
|
|
|
-
|
|
|
- - python .\views\construction_review\app.py
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- pip install aioredis -i https://mirrors.aliyun.com/pypi/simple/
|
|
|
- pip install langgraph-checkpoint-postgres -i https://mirrors.aliyun.com/pypi/simple/
|
|
|
- pip install langchain-redis -i https://mirrors.aliyun.com/pypi/simple/
|
|
|
-
|
|
|
-
|
|
|
-### 增加组件依赖
|
|
|
- pip install aiomysql -i https://mirrors.aliyun.com/pypi/simple/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-### 向量模型和重排序模型测试
|
|
|
- cd LQAgentPlatform
|
|
|
- python foundation/models/silicon_flow.py
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-### 测试接口
|
|
|
-
|
|
|
- #### 生成模型接口
|
|
|
- - chat
|
|
|
- http://localhost:8001/test/generate/chat
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"111"
|
|
|
- },
|
|
|
- "input": "你好"
|
|
|
- }
|
|
|
- - stream
|
|
|
- http://localhost:8001/test/generate/stream
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"111"
|
|
|
- },
|
|
|
- "input": "你好,我叫小红,你叫什么?"
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- #### agent 智能体
|
|
|
- - chat
|
|
|
- http://localhost:8001/test/agent/stream
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"111"
|
|
|
- },
|
|
|
- "input": "你好"
|
|
|
- }
|
|
|
-
|
|
|
- - stream
|
|
|
-curl -X POST "http://localhost:8001/test/agent/stream" \
|
|
|
--H "Content-Type: application/json" \
|
|
|
--d '{
|
|
|
- "config": {
|
|
|
- "session_id": "111"
|
|
|
- },
|
|
|
- "input": "你好"
|
|
|
-}'
|
|
|
-
|
|
|
- #### Workflow-Graph stream
|
|
|
- - chat
|
|
|
- http://localhost:8001/test/graph/stream
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"111"
|
|
|
- },
|
|
|
- "input": "你好"
|
|
|
- }
|
|
|
-
|
|
|
- - agent
|
|
|
- http://localhost:8001/test/graph/stream
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"111"
|
|
|
- },
|
|
|
- "input": "查询信息"
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-### MySQL 数据库操作测试
|
|
|
- - 新增
|
|
|
- http://localhost:8001/test/mysql/add
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"10002"
|
|
|
- },
|
|
|
- "input": "张三"
|
|
|
- }
|
|
|
- - 查询列表
|
|
|
- http://localhost:8001/test/mysql/list
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"10002"
|
|
|
- },
|
|
|
- "input": "张三"
|
|
|
- }
|
|
|
-
|
|
|
- - 查询单个
|
|
|
- http://localhost:8001/test/mysql/get
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"10002"
|
|
|
- },
|
|
|
- "input": "4"
|
|
|
- }
|
|
|
-
|
|
|
- - 修改
|
|
|
- http://localhost:8001/test/mysql/update
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"1"
|
|
|
- },
|
|
|
- "input": "李四"
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-#### 向量检索测试
|
|
|
- - 向量检索测试
|
|
|
- http://localhost:8001/test/bfp/search
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"20"
|
|
|
- },
|
|
|
- "input": "安全生产条件"
|
|
|
- }
|
|
|
-
|
|
|
- - 向量检索和重排序测试
|
|
|
- - http://localhost:8001/test/bfp/search/rerank
|
|
|
- {
|
|
|
- "config": {
|
|
|
- "session_id":"20"
|
|
|
- },
|
|
|
- "input": "安全生产条件"
|
|
|
- }
|
|
|
+施工方案智能审查与编写系统(FastAPI + LangGraph + Celery)
|
|
|
|
|
|
+## 环境安装
|
|
|
|
|
|
+```bash
|
|
|
+# 1. 安装生产依赖
|
|
|
+pip install -r requirements/base.txt -i https://mirrors.aliyun.com/pypi/simple/
|
|
|
+
|
|
|
+# 2. 安装开发依赖(可选,含 pytest/ruff/mypy)
|
|
|
+pip install -r requirements/dev.txt -i https://mirrors.aliyun.com/pypi/simple/
|
|
|
+
|
|
|
+# 3. 注册项目路径(替代 sys.path.insert,秒级完成)
|
|
|
+pip install -e .
|
|
|
+```
|
|
|
+
|
|
|
+## 启动服务
|
|
|
+
|
|
|
+```bash
|
|
|
+# 开发模式(单进程)
|
|
|
+uvicorn server.app:app --port=8001 --host=0.0.0.0
|
|
|
+
|
|
|
+# 开发模式(含 Celery Worker)
|
|
|
+python server/app.py --host 0.0.0.0 --port 8001
|
|
|
+
|
|
|
+# 生产模式(多进程)
|
|
|
+gunicorn -c gunicorn_config.py server.app:app
|
|
|
+```
|
|
|
+
|
|
|
+## Docker 部署
|
|
|
+
|
|
|
+```bash
|
|
|
+# 首次或依赖变更时:构建 base 镜像(耗时较长)
|
|
|
+docker build -f Dockerfile.base -t lq-agent-base:latest .
|
|
|
+
|
|
|
+# 日常构建:秒级(仅复制源码)
|
|
|
+docker build -t lq_agent_platform_server_dev:v1.0 .
|
|
|
+
|
|
|
+# 启动
|
|
|
+docker-compose -f docker/docker-compose.yml up -d
|
|
|
+```
|
|
|
+
|
|
|
+## 运行测试
|
|
|
+
|
|
|
+```bash
|
|
|
+pytest utils_test/<TestDir>/
|
|
|
+```
|
|
|
+
|
|
|
+## 项目结构
|
|
|
+
|
|
|
+```
|
|
|
+server/ — 应用入口(app/factory/routes/celery_manager/runner)
|
|
|
+views/ — API 路由层
|
|
|
+core/ — 业务逻辑(审查引擎、编写引擎、工作流编排)
|
|
|
+foundation/ — 基础设施(AI 模型、数据库、Redis、Celery、链路追踪)
|
|
|
+config/ — 配置文件 & Prompt 模板
|
|
|
+requirements/ — 依赖清单(base.txt 生产 / dev.txt 开发)
|
|
|
+data_pipeline/ — Milvus 向量库灌入工具
|
|
|
+utils_test/ — 按模块组织的测试套件
|
|
|
+```
|
|
|
+
|
|
|
+## API 路由前缀
|
|
|
+
|
|
|
+| 前缀 | 功能 |
|
|
|
+|------|------|
|
|
|
+| `/sgsc` | 施工方案审查 |
|
|
|
+| `/sgbx` | 施工方案编写 |
|
|
|
+| `/health` | 健康检查 |
|
|
|
+| `/celery/status` | Celery 状态 |
|
|
|
+
|
|
|
+## 架构约束
|
|
|
+
|
|
|
+- `views/` 禁止直接导入 `foundation/database/`
|
|
|
+- `core/component/` 禁止直接导入 `foundation/database/`
|
|
|
+- 配置读取通过 `config_handler.get(section, key)`
|
|
|
+- 提交前运行 `python scripts/check_imports.py`
|