docs: 更新文档路径引用,移除硬编码密钥,修复 Docker 配置
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 7m1s

This commit is contained in:
2026-04-22 00:43:06 +08:00
parent 38646001e6
commit a869d884b7
7 changed files with 125 additions and 90 deletions

157
README.md
View File

@@ -169,59 +169,73 @@ stateDiagram-v2
```
Agent1/
├── app/
│ ├── __init__.py
│ ├── config.py # 配置管理
│ ├── logger.py # 日志工具
│ ├── backend.py # FastAPI 后端应用
│ ├── agent/
├── backend/
│ ├── app/
│ │ ├── __init__.py
│ │ ├── service.py # Agent 服务核心
│ │ ├── llm_factory.py # LLM 工厂
│ │ ├── history.py # 历史查询服务
│ │ ├── prompts.py # 提示模板
│ │ └── rag_initializer.py # RAG 工具初始化
├── graph/
│ │ ├── __init__.py
│ │ ├── graph_builder.py # LangGraph 图构建器
│ │ ├── graph_tools.py # 工具定义
│ │ ├── state.py # 状态定义
│ │ ── retrieve_memory.py # 记忆检索
├── nodes/
│ │ ├── __init__.py
│ │ ├── router.py # 路由决策
│ │ ├── llm_call.py # LLM 调用节点
│ │ ├── tool_call.py # 工具执行节点
│ │ ├── retrieve_memory.py # 记忆检索节点
│ │ ├── summarize.py # 记忆存储节点
│ │ ├── finalize.py # 最终处理节点
│ │ └── memory_trigger.py # 记忆触发节点
├── memory/
│ │ ├── __init__.py
│ │ └── mem0_client.py # Mem0 客户端封装
├── rag/
│ │ ├── __init__.py
│ │ ├── retriever.py # 检索器
│ │ ├── reranker.py # 重排序
│ │ ├── query_transform.py # 查询转换
│ │ ├── pipeline.py # RAG 流水线
│ │ ├── fusion.py # RAG-Fusion
│ │ └── tools.py # RAG 工具
└── utils/
└── __init__.py
├── frontend/
├── __init__.py
├── frontend_main.py # Streamlit 主入口
├── api_client.py # API 客户端
├── config.py # 前端配置
── state.py # 状态管理
│ ├── logger.py # 日志
│ ├── utils.py # 工具函数
│ └── components/
│ │ ├── config.py # 配置管理
│ │ ├── logger.py # 日志工具
│ │ ├── backend.py # FastAPI 后端应用
│ │ ├── agent/
│ │ │ ├── __init__.py
│ │ ├── service.py # Agent 服务核心
│ │ │ ├── llm_factory.py # LLM 工厂
│ │ │ ├── history.py # 历史查询服务
│ │ │ ├── prompts.py # 提示模板
│ │ │ └── rag_initializer.py # RAG 工具初始化
│ │ ── graph/
│ │ ├── __init__.py
│ │ │ ├── graph_builder.py # LangGraph 图构建器
│ │ │ ├── graph_tools.py # 工具定义
│ │ │ ├── state.py # 状态定义
│ │ │ └── retrieve_memory.py # 记忆检索
│ │ ├── nodes/
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 路由决策
│ │ │ ├── llm_call.py # LLM 调用节点
│ │ ├── tool_call.py # 工具执行节点
│ │ │ ├── retrieve_memory.py # 记忆检索节点
│ │ │ ├── summarize.py # 记忆存储节点
│ │ ├── finalize.py # 最终处理节点
│ │ │ └── memory_trigger.py # 记忆触发节点
│ │ ├── memory/
│ │ │ ├── __init__.py
│ │ │ └── mem0_client.py # Mem0 客户端封装
│ │ ├── rag/
│ │ │ ├── __init__.py
│ │ │ ├── retriever.py # 检索器
│ │ ├── reranker.py # 重排序
│ ├── query_transform.py # 查询转换
│ │ │ ├── pipeline.py # RAG 流水线
│ │ ├── fusion.py # RAG-Fusion
│ │ └── tools.py # RAG 工具
│ └── utils/
│ └── __init__.py
── rag_core/
│ ├── __init__.py
│ ├── sidebar.py # 侧边栏组件
│ ├── chat_area.py # 聊天区域组件
── info_panel.py # 信息面板组件
│ ├── client.py # RAG 核心客户端
│ ├── embedders.py # 嵌入模型
── vector_store.py # 向量存储
│ ├── retriever_factory.py # 检索器工厂
│ └── store/
│ ├── __init__.py
│ ├── factory.py # 存储工厂
│ └── postgres.py # PostgreSQL 存储
├── frontend/
│ ├── run.py # 前端启动脚本
│ ├── requirements.txt
│ └── src/
│ ├── __init__.py
│ ├── frontend_main.py # Streamlit 主入口
│ ├── api_client.py # API 客户端
│ ├── config.py # 前端配置
│ ├── state.py # 状态管理
│ ├── logger.py # 日志
│ ├── utils.py # 工具函数
│ └── components/
│ ├── __init__.py
│ ├── sidebar.py # 侧边栏组件
│ ├── chat_area.py # 聊天区域组件
│ └── info_panel.py # 信息面板组件
├── rag_indexer/
│ ├── __init__.py
│ ├── cli.py # 命令行入口
@@ -229,22 +243,20 @@ Agent1/
│ ├── loaders.py # 文档加载器
│ ├── splitters.py # 文本切分器
│ └── test/ # 测试脚本
├── rag_core/
│ ├── __init__.py
│ ├── client.py # RAG 核心客户端
│ ├── embedders.py # 嵌入模型
│ ├── vector_store.py # 向量存储
│ ├── retriever_factory.py # 检索器工厂
│ └── store/
│ ├── __init__.py
│ ├── factory.py # 存储工厂
│ └── postgres.py # PostgreSQL 存储
├── docker/
│ ├── docker-compose.yml # Docker 服务编排
│ ├── Dockerfile.backend # 后端镜像构建
│ └── Dockerfile.frontend # 端镜像构建
│ ├── backend/
│ └── Dockerfile # 端镜像构建
│ ├── frontend/
│ │ └── Dockerfile # 前端镜像构建
│ └── models/ # spaCy 模型文件
├── scripts/
│ └── start.sh # 启动脚本
├── test/ # 测试目录
│ ├── test_backend.py
│ ├── test_rag.py
│ ├── test_dqrant.py
│ └── test_rag_indexer_result.py
├── .gitea/
│ └── workflows/
│ └── deploy.yml # CI/CD 自动化部署
@@ -584,7 +596,7 @@ RAG 系统分为两个独立但协同的阶段:
│ └────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ 阶段二:在线检索生成 (app/rag) │
│ 阶段二:在线检索生成 (backend/app/rag) │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ 用户查询 → 查询改写 → 多路检索 → RRF 融合 → 重排序 │ │
│ │ MultiQuery Dense+Sparse Cross-Encoder │ │
@@ -803,10 +815,13 @@ cp .env.docker .env
# 编辑 .env根据本地/远程环境调整配置
# 3. 启动后端
python app/backend.py
python backend/app/backend.py
# 4. 启动前端(新终端)
streamlit run frontend/frontend_main.py
streamlit run frontend/src/frontend_main.py
# 或者使用启动脚本(推荐)
./scripts/start.sh both
```
---
@@ -851,7 +866,7 @@ streamlit run frontend/frontend_main.py
### 添加新工具
在 [app/graph/graph_tools.py](file:///home/huang/Study/AIProject/Agent1/app/graph/graph_tools.py) 中添加新的 `@tool` 装饰函数:
在 [backend/app/graph/graph_tools.py](file:///home/huang/Study/AIProject/Agent1/backend/app/graph/graph_tools.py) 中添加新的 `@tool` 装饰函数:
```python
@tool
@@ -873,7 +888,7 @@ def my_new_tool(param: str) -> str:
### 添加新模型
在 [app/agent/llm_factory.py](file:///home/huang/Study/AIProject/Agent1/app/agent/llm_factory.py) 中添加模型创建方法:
在 [backend/app/agent/llm_factory.py](file:///home/huang/Study/AIProject/Agent1/backend/app/agent/llm_factory.py) 中添加模型创建方法:
```python
@staticmethod
@@ -1096,7 +1111,7 @@ curl -X POST http://localhost:6333/collections/my_docs/actions \
#### 3.1 添加自定义工具
```python
# 在 app/graph/graph_tools.py 中添加
# 在 backend/app/graph/graph_tools.py 中添加
from langchain_core.tools import tool
from typing import Optional
@@ -1154,7 +1169,7 @@ def calculate_expression(
#### 3.2 添加自定义 LLM 提供商
```python
# 在 app/agent/llm_factory.py 中添加
# 在 backend/app/agent/llm_factory.py 中添加
from langchain_openai import ChatOpenAI
from langchain_core.language_models import BaseChatModel
@@ -1186,7 +1201,7 @@ class LLMFactory:
#### 3.3 添加自定义 RAG 检索器
```python
# 在 app/rag/retriever.py 中添加
# 在 backend/app/rag/retriever.py 中添加
from langchain_core.retrievers import BaseRetriever
from langchain_core.documents import Document