# llamaindex-rag **Repository Path**: happy_source/llamaindex-rag ## Basic Information - **Project Name**: llamaindex-rag - **Description**: 基于LlamIndex RAG 的企业 Linux 运维值班助手 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-26 - **Last Updated**: 2026-05-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 企业 Linux 运维值班助手 基于 [LlamaIndex](https://www.llamaindex.ai/) 构建的 Linux 运维知识库 RAG 问答系统。通过 SiliconFlow 提供的 LLM、Embedding 和 Rerank 服务,对本地 Markdown 文档进行检索增强生成,支持分类筛选和多轮对话。 ## 功能特性 - **知识库问答** — 基于 `data/` 目录下的 Markdown 文档,检索相关内容并生成回答 - **分类筛选** — 支持按"命令行"、"运维"、"软件运维"、"通用"分类限定查询范围 - **多轮对话** — 支持上下文连续对话,可在 Web 和 CLI 两种模式下使用 - **流式输出** — 回答逐字流式输出,响应更及时 - **Rerank 重排序** — 使用 BAAI/bge-reranker-v2-m3 对检索结果重排序,提升回答质量 ## 项目结构 ``` . ├── app.py # Gradio Web 界面入口 ├── chat_cli.py # CLI 交互模式入口 ├── build_index.py # 独立构建索引脚本 ├── query_test.py # 单轮问答测试脚本 ├── linux_ops_assistant.py # 核心助手类(索引构建、查询引擎) ├── linux_ops_chat_assistant.py # 聊天助手类(多轮对话引擎) ├── data/ # 知识库文档(Markdown) │ ├── cli/ # 命令行类文档 │ ├── ops/ # 运维类文档 │ └── soft/ # 软件运维类文档 ├── storage/ # 向量索引持久化目录(自动生成) ├── pyproject.toml └── uv.lock ``` ## 环境要求 - Python >= 3.11 - [uv](https://docs.astral.sh/uv/)(可选,项目使用 uv 管理依赖) - SiliconFlow API Key([获取地址](https://siliconflow.cn/)) ## 快速开始 ### 1. 克隆项目并安装依赖 ```bash git clone cd llamaindex-rag # 使用 uv(推荐) uv sync # 或使用 pip pip install -r requirements.txt ``` ### 2. 配置环境变量 ```bash cp .env.example .env # 编辑 .env,填入你的 SiliconFlow API Key ``` ### 3. 构建索引 首次运行前需要从 `data/` 目录的文档构建向量索引: ```bash python build_index.py ``` 索引构建完成后保存在 `storage/` 目录,后续启动无需重复构建。 ### 4. 启动应用 **Web 模式(Gradio):** ```bash python app.py ``` 浏览器访问 http://127.0.0.1:7860 **CLI 模式:** ```bash python chat_cli.py ``` ## Docker 部署 ### 构建并启动 ```bash # 确保 .env 文件已配置 SILICONFLOW_API_KEY docker compose up -d --build ``` 访问 http://localhost:7860 ### 常用命令 ```bash # 查看日志 docker compose logs -f # 停止服务 docker compose down # 重新构建(文档更新后) docker compose up -d --build ``` ### 数据卷说明 | 卷挂载 | 说明 | |---|---| | `./data:/app/data:ro` | 知识库文档(只读) | | `./storage:/app/storage` | 向量索引持久化(读写) | > 添加新文档后需要重新构建索引:先删除 `storage/` 目录,再重启容器。 ## 技术栈 | 组件 | 说明 | |---|---| | LLM | deepseek-ai/DeepSeek-V3.2(SiliconFlow) | | Embedding | BAAI/bge-m3(SiliconFlow) | | Reranker | BAAI/bge-reranker-v2-m3(SiliconFlow) | | 框架 | LlamaIndex | | Web UI | Gradio | ## License MIT