# agent **Repository Path**: xiaoaoc/agent ## Basic Information - **Project Name**: agent - **Description**: 用以记录自己学习AI相关技术所做的一些demo - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-30 - **Last Updated**: 2026-07-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 智能文档系统 (Smart Document System) 基于 AI 的企业级智能文档管理平台,支持文档上传/解析、向量+全文混合检索、RAG 智能问答。详细架构设计见 [ARCHITECTURE.md](ARCHITECTURE.md)。 ## 技术栈 ### 前端 | 技术 | 版本 | 说明 | |------|------|------| | [Vue 3](https://vuejs.org/) | ^3.5 | 渐进式前端框架 | | [TypeScript](https://www.typescriptlang.org/) | ~6.0 | 类型安全 | | [Vite](https://vitejs.dev/) | ^8.1 | 构建工具 | | [Element Plus](https://element-plus.org/) | ^2.14 | UI 组件库 | | [Pinia](https://pinia.vuejs.org/) | ^3.0 | 状态管理 | | [Vue Router](https://router.vuejs.org/) | ^4.6 | 路由 | | [Axios](https://axios-http.com/) | ^1.18 | HTTP 客户端 | | [PDF.js](https://mozilla.github.io/pdf.js/) | ^6.0 | PDF 渲染 | | [marked](https://marked.js.org/) | ^18.0 | Markdown 解析 | ### Java 后端 | 技术 | 版本 | 说明 | |------|------|------| | [Spring Boot](https://spring.io/projects/spring-boot) | 4.1.0 | 业务中间层,对外 REST API | | Java | 21 | 运行环境 | | Spring Data JPA | — | ORM 持久化 | | MySQL | — | 文档元数据存储 | | [MinIO Client](https://min.io/) | 8.5.7 | 对象存储 SDK | | Spring AMQP (RabbitMQ) | — | 消息队列 | | Elasticsearch Java Client | 8.13.4 | 全文检索 | | Spring WebFlux | — | 异步调用 Python AI 服务 | ### Python AI 服务 | 技术 | 版本 | 说明 | |------|------|------| | [FastAPI](https://fastapi.tiangolo.com/) | 0.104 | 高性能异步 Web 框架 | | [LangChain](https://www.langchain.com/) / [LangGraph](https://langchain-ai.github.io/langgraph/) | ≥0.3 | AI 编排 & Agent 工作流 | | [sentence-transformers](https://www.sbert.net/) | ≥3.0 | Embedding & Rerank 模型加载(BGE 系列) | | [PyMilvus](https://milvus.io/) | ≥2.4 | 向量数据库 SDK | | Elasticsearch | ≥8.12 | 全文检索 | | MinIO | ≥7.2 | 对象存储 | | [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) | ≥3.0 | OCR 文字识别(降级方案) | | [PyMuPDF](https://pymupdf.readthedocs.io/) | ≥1.24 | PDF 解析(降级方案) | | [MinerU](https://github.com/opendatalab/MinerU) | latest | 高质量 PDF 解析(保留表格/公式/排版) | | aio-pika / pika | — | RabbitMQ 客户端 | | OpenAI SDK | ≥1.0 | LLM 调用 | ### 基础设施 | 组件 | 用途 | |------|------| | **MySQL** | 文档元数据、用户数据 | | **MinIO** | 原始文件 & 解析结果对象存储 | | **RabbitMQ** | 文档解析任务异步队列 | | **Milvus** | 向量嵌入存储与语义检索 | | **Elasticsearch** | BM25 全文检索 + 混合搜索 | | **MinerU API** | 高精度 PDF 解析(可选,独立部署) | ## 项目结构 ``` ├── smart-doc-frontend/ # Vue 3 前端 │ └── src/ │ ├── api/ # 后端 API 调用 │ ├── components/ # 可复用组件 (chat/document/pdf/search) │ ├── composables/ # 组合式函数(PDF渲染、状态轮询、高亮覆盖层) │ ├── router/ # 路由配置 │ ├── stores/ # Pinia 状态管理 │ └── types/ # TypeScript 类型定义 ├── java_service/ # Spring Boot 后端 │ └── src/main/java/com/xiaoao/java_service/ │ ├── config/ # 配置类(CORS/MinIO/ES/RabbitMQ) │ ├── controller/ # REST 控制器 │ ├── entity/ # JPA 实体 │ ├── repository/ # JPA 仓库 │ ├── service/ # 业务逻辑 │ └── dto/ # 数据传输对象 ├── python_service/ # FastAPI AI 服务 │ ├── api/ # 路由(chat/document/search) │ ├── config/ # 配置管理(pydantic-settings) │ ├── core/ # 核心工具 │ ├── models/ # 数据模型 │ ├── mq/ # RabbitMQ 消费者 & 任务调度 │ ├── scripts/ # 模型下载脚本 │ └── services/ # 核心服务 │ ├── agent_service.py # AI Agent 编排 │ ├── embedding_service.py # Embedding & Rerank │ ├── milvus_service.py # 向量数据库操作 │ ├── es_service.py # Elasticsearch 全文检索 │ ├── rag_service.py # RAG 检索增强生成 │ ├── pipeline_service.py # 文档处理流水线 │ ├── chunking_service.py # 文本分块 │ ├── mineru_client.py # MinerU API 调用 │ ├── ocr_service.py # OCR 文字识别 │ ├── pdf_parser.py # PDF 解析(降级方案) │ ├── markdown_converter.py # Markdown 转换 │ ├── layout_analyzer.py # 版面分析 │ └── coordinate_generator.py # 坐标映射 ├── doc/ # 项目文档 └── 前端开发指导文档.md # 前端开发指南 ``` ## 系统架构 ``` ┌──────────────────────────────────────────────────────┐ │ 用户浏览器 │ │ (Vue 3 + Element Plus) │ └─────────┬────────────────────────────┬────────────────┘ │ HTTP/REST │ HTTP/REST ▼ ▼ ┌──────────────────┐ ┌──────────────────────────────┐ │ Java Service │ │ Python AI Service │ │ (Spring Boot │◄──►│ (FastAPI :8000) │ │ :8080) │ │ │ │ │ │ ┌────────────────────────┐ │ │ ┌────────────┐ │ │ │ 文档处理流水线 │ │ │ │ 文档 CRUD │ │ │ │ PDF→OCR/MinerU→Markdown │ │ │ │ 搜索 API │ │ │ │ →分块→Embedding→入库 │ │ │ │ 文件管理 │ │ │ └────────────────────────┘ │ │ └────────────┘ │ │ ┌────────────────────────┐ │ │ │ │ │ │ RAG 检索增强生成 │ │ │ │ │ │ │ Milvus+ES混合检索→Rerank│ │ │ │ │ │ │ →LLM生成答案 │ │ │ │ │ │ └────────────────────────┘ │ └───────┬┴─────────┘ └──────┬───────────────────────┘ │ │ ▼ ▼ ┌──────────────────────────────────────────────────────┐ │ 基础设施层 │ │ ┌────────┐ ┌──────────┐ ┌────────┐ ┌────────────┐ │ │ │ MySQL │ │ RabbitMQ │ │ MinIO │ │ MinerU API │ │ │ │ :3306 │ │ :5672 │ │ :9000 │ │ :8001 │ │ │ └────────┘ └──────────┘ └────────┘ └────────────┘ │ │ ┌────────┐ ┌──────────┐ │ │ │ Milvus │ │ ES │ │ │ │ :19530 │ │ :9200 │ │ │ └────────┘ └──────────┘ │ └──────────────────────────────────────────────────────┘ ``` ## 快速开始 ### 前置要求 - **Node.js** ≥ 18 - **Java** ≥ 21 - **Python** ≥ 3.10 - **Maven** ≥ 3.8 - **Docker** & **Docker Compose**(用于启动基础设施) ### 1. 克隆项目 ```bash git clone cd agent ``` ### 2. 启动基础设施(Docker) 一键启动 MySQL、RabbitMQ、MinIO、Milvus、Elasticsearch: ```bash docker-compose up -d ``` > 如果本地没有 `docker-compose.yml`,可以手动启动各个组件(见下方[基础设施手动部署](#基础设施手动部署))。 ### 3. 启动 Python AI 服务 ```bash cd python_service # 创建虚拟环境 python -m venv venv # Windows venv\Scripts\activate # macOS / Linux source venv/bin/activate # 安装依赖 pip install -r requirements.txt # (可选)下载 Embedding / Rerank 模型 python scripts/download_models.py # 配置环境变量(复制模板并修改) cp .env.example .env # 启动服务(默认 :8000) python app.py ``` ### 4. 启动 Java 后端 ```bash cd java_service # 编译并启动(默认 :8080) mvn spring-boot:run ``` ### 5. 启动前端 ```bash cd smart-doc-frontend # 安装依赖 npm install # 启动开发服务器(默认 :5173) npm run dev ``` ### 6. 打开浏览器 访问 `http://localhost:5173` 即可使用。 ## Docker 部署 ### 总体架构 ``` ┌─────────────────────────┐ │ Nginx (frontend :80) │ │ Vue 3 生产构建 │ └─────┬──────────┬─────────┘ │ /api │ /ai ▼ ▼ ┌──────────────────────┐ ┌────────────────────────┐ │ Java (:8080) │ │ Python AI (:8000) │ │ Spring Boot 4.1 │ │ FastAPI │ └──┬───┬───┬───────────┘ └──┬───┬───┬──────────────┘ │ │ │ │ │ │ ┌──────┘ │ └──────┐ ┌─────┘ │ └─────┐ ▼ ▼ ▼ ▼ ▼ ▼ MySQL RabbitMQ MinIO Milvus ES MinerU :3306 :5672 :9000 :19530 :9200 :8001 ``` --- ### 第一步:基础设施 docker-compose.yml 在项目根目录创建 `docker-compose.yml`,包含所有中间件: ```yaml version: '3.8' # ============================================================ # 共享网络,所有服务通过服务名互相访问 # ============================================================ networks: smart-doc-net: driver: bridge services: # ============================================================ # MySQL — 文档元数据 # ============================================================ mysql: image: mysql:8.0 container_name: smart-doc-mysql restart: unless-stopped environment: MYSQL_ROOT_PASSWORD: 12345678 MYSQL_DATABASE: xiaoao_doc MYSQL_CHARSET: utf8mb4 MYSQL_COLLATION: utf8mb4_unicode_ci ports: - "3306:3306" volumes: - mysql_data:/var/lib/mysql - ./java_service/src/main/resources/db/init.sql:/docker-entrypoint-initdb.d/init.sql networks: - smart-doc-net healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p$$MYSQL_ROOT_PASSWORD"] interval: 10s timeout: 5s retries: 5 # ============================================================ # RabbitMQ — 文档解析任务队列 # ============================================================ rabbitmq: image: rabbitmq:3.12-management container_name: smart-doc-rabbitmq restart: unless-stopped environment: RABBITMQ_DEFAULT_USER: guest RABBITMQ_DEFAULT_PASS: guest ports: - "5672:5672" # AMQP - "15672:15672" # 管理后台 http://localhost:15672 volumes: - rabbitmq_data:/var/lib/rabbitmq networks: - smart-doc-net healthcheck: test: ["CMD", "rabbitmq-diagnostics", "check_port_connectivity"] interval: 10s timeout: 5s retries: 5 # ============================================================ # MinIO — 文件对象存储(应用使用) # ============================================================ minio: image: minio/minio:latest container_name: smart-doc-minio restart: unless-stopped command: server /data --console-address ":9001" environment: MINIO_ROOT_USER: minioadmin MINIO_ROOT_PASSWORD: minioadmin ports: - "9000:9000" # S3 API - "9001:9001" # Web Console http://localhost:9001 volumes: - minio_data:/data networks: - smart-doc-net healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 10s timeout: 5s retries: 5 # ============================================================ # Elasticsearch — 全文检索 # ============================================================ elasticsearch: image: elasticsearch:8.13.4 container_name: smart-doc-es restart: unless-stopped environment: - discovery.type=single-node - xpack.security.enabled=false - "ES_JAVA_OPTS=-Xms1g -Xmx1g" ports: - "9200:9200" volumes: - es_data:/usr/share/elasticsearch/data networks: - smart-doc-net healthcheck: test: ["CMD-SHELL", "curl -s http://localhost:9200/_cluster/health | grep -q 'green\|yellow'"] interval: 15s timeout: 10s retries: 10 # ============================================================ # etcd — Milvus 元数据存储 # ============================================================ etcd: image: quay.io/coreos/etcd:v3.5.5 container_name: milvus-etcd restart: unless-stopped environment: - ETCD_AUTO_COMPACTION_MODE=revision - ETCD_AUTO_COMPACTION_RETENTION=1000 - ETCD_QUOTA_BACKEND_BYTES=4294967296 command: etcd -advertise-client-urls=http://etcd:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd volumes: - etcd_data:/etcd networks: - smart-doc-net healthcheck: test: ["CMD", "etcdctl", "endpoint", "health"] interval: 10s timeout: 5s retries: 5 # ============================================================ # Milvus 内置 MinIO — 向量数据存储(独立于应用 MinIO) # ============================================================ minio-milvus: image: minio/minio:latest container_name: milvus-minio restart: unless-stopped command: minio server /data environment: MINIO_ROOT_USER: minioadmin MINIO_ROOT_PASSWORD: minioadmin volumes: - milvus_minio_data:/data networks: - smart-doc-net healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 10s timeout: 5s retries: 5 # ============================================================ # Milvus — 向量数据库 # ============================================================ milvus: image: milvusdb/milvus:v2.4.0 container_name: milvus-standalone restart: unless-stopped command: ["milvus", "run", "standalone"] environment: ETCD_ENDPOINTS: etcd:2379 MINIO_ADDRESS: minio-milvus:9000 MINIO_ACCESS_KEY_ID: minioadmin MINIO_SECRET_ACCESS_KEY: minioadmin ports: - "19530:19530" depends_on: etcd: condition: service_healthy minio-milvus: condition: service_healthy networks: - smart-doc-net healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"] interval: 15s timeout: 10s retries: 10 volumes: mysql_data: rabbitmq_data: minio_data: es_data: etcd_data: milvus_minio_data: ``` 启动基础设施: ```bash # 启动所有中间件 docker-compose up -d # 查看启动状态 docker-compose ps # 查看日志(排查启动问题) docker-compose logs -f ``` --- ### 第二步:MinerU 文档解析服务部署 [MinerU](https://github.com/opendatalab/MinerU) 是本系统的核心 PDF 解析引擎,能够高质量保留表格、公式、排版结构。 本系统通过 HTTP 调用 MinerU API(`/file_parse` 接口),不可用时自动降级到 PyMuPDF + PaddleOCR。 MinerU 的详细安装与部署请参考官方文档: - **GitHub**:[https://github.com/opendatalab/MinerU](https://github.com/opendatalab/MinerU) - **官方文档**:[https://opendatalab.github.io/MinerU/](https://opendatalab.github.io/MinerU/) > 部署完成后,在 `.env` 中配置 `MINERU_API_URL=http://:8001` 即可接入本系统。 --- ### 第三步:应用服务 Docker 化 #### 1. Python AI 服务 ```dockerfile # python_service/Dockerfile FROM python:3.11-slim WORKDIR /app # 系统依赖(PaddleOCR / PyMuPDF 所需) RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender-dev \ libgomp1 libmagic1 \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt \ -i https://mirrors.aliyun.com/pypi/simple COPY . . # 创建模型缓存和临时文件目录 RUN mkdir -p /app/models /app/temp EXPOSE 8000 # 环境变量可通过 docker run -e 或 .env 文件传入 ENV HF_ENDPOINT=https://hf-mirror.com ENV HF_HUB_CACHE=/app/models CMD ["python", "app.py"] ``` 构建并启动: ```bash cd python_service # 构建镜像 docker build -t smart-doc-python . # 启动(加入 smart-doc-net 网络,通过服务名访问中间件) docker run -d \ --name smart-doc-python \ --network smart-doc-net \ -p 8000:8000 \ -e LLM_API_KEY=sk-your-key \ -e LLM_API_BASE=https://api.deepseek.com \ -e LLM_MODEL=deepseek-chat \ -e MINERU_API_URL=http://smart-doc-mineru:8001 \ -e MINIO_ENDPOINT=minio:9000 \ -e RABBITMQ_HOST=rabbitmq \ -e ES_HOSTS=http://elasticsearch:9200 \ -e MILVUS_HOST=milvus \ -v huggingface_models:/app/models \ -v ./temp:/app/temp \ smart-doc-python ``` > **关键配置**:容器内通过 Docker 网络的服务名(`minio`、`rabbitmq`、`elasticsearch`、`milvus`)访问中间件,不再是 `localhost`。 #### 2. Java 后端 ```dockerfile # java_service/Dockerfile FROM maven:3.9-eclipse-temurin-21 AS build WORKDIR /app COPY pom.xml . RUN mvn dependency:go-offline -B COPY src ./src RUN mvn clean package -DskipTests -B FROM eclipse-temurin:21-jre WORKDIR /app COPY --from=build /app/target/java_service-0.0.1-SNAPSHOT.jar app.jar EXPOSE 8080 # JVM 参数:可根据内存调整 ENTRYPOINT ["java", "-Xmx512m", "-jar", "app.jar"] ``` 构建并启动: ```bash cd java_service # 构建镜像(多阶段构建,自动编译) docker build -t smart-doc-java . # 启动 docker run -d \ --name smart-doc-java \ --network smart-doc-net \ -p 8080:8080 \ -e SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/xiaoao_doc?useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai \ -e SPRING_RABBITMQ_HOST=rabbitmq \ -e MINIO_ENDPOINT=http://minio:9000 \ -e ELASTICSEARCH_HOST=elasticsearch \ -e PYTHON_AI_URL=http://smart-doc-python:8000 \ smart-doc-java ``` #### 3. 前端(多阶段构建 + Nginx) ```dockerfile # smart-doc-frontend/Dockerfile FROM node:20-alpine AS build WORKDIR /app # 利用 Docker 缓存层 COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # 生产阶段 FROM nginx:alpine COPY --from=build /app/dist /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] ``` ```nginx # smart-doc-frontend/nginx.conf server { listen 80; server_name localhost; # gzip 压缩 gzip on; gzip_types text/plain application/json text/css application/javascript text/markdown; # 前端静态资源 location / { root /usr/share/nginx/html; index index.html; try_files $uri $uri/ /index.html; } # 代理到 Java 后端 location /api/ { proxy_pass http://smart-doc-java:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_read_timeout 120s; } # 代理到 Python AI 服务(WebSocket 用于流式对话) location /ai/ { proxy_pass http://smart-doc-python:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_read_timeout 120s; proxy_buffering off; } } ``` 构建并启动: ```bash cd smart-doc-frontend docker build -t smart-doc-frontend . docker run -d \ --name smart-doc-frontend \ --network smart-doc-net \ -p 80:80 \ smart-doc-frontend ``` --- ### 第四步:一键部署 docker-compose.yml(全栈) 将以下内容追加到第一步的 `docker-compose.yml` 中,实现一键全栈部署: ```yaml # ============================================================ # 应用服务 # ============================================================ python-ai: build: ./python_service container_name: smart-doc-python restart: unless-stopped environment: # LLM LLM_API_KEY: ${LLM_API_KEY} LLM_API_BASE: ${LLM_API_BASE:-https://api.deepseek.com} LLM_MODEL: ${LLM_MODEL:-deepseek-chat} # 中间件(通过 Docker 网络服务名访问) MINERU_API_URL: http://smart-doc-mineru:8001 MINIO_ENDPOINT: minio:9000 RABBITMQ_HOST: rabbitmq ES_HOSTS: http://elasticsearch:9200 MILVUS_HOST: milvus # 国内镜像加速 HF_ENDPOINT: https://hf-mirror.com ports: - "8000:8000" volumes: - huggingface_models:/app/models - python_temp:/app/temp networks: - smart-doc-net depends_on: rabbitmq: condition: service_healthy minio: condition: service_healthy elasticsearch: condition: service_healthy milvus: condition: service_healthy java-backend: build: ./java_service container_name: smart-doc-java restart: unless-stopped environment: SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/xiaoao_doc?useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai SPRING_RABBITMQ_HOST: rabbitmq MINIO_ENDPOINT: http://minio:9000 ELASTICSEARCH_HOST: elasticsearch PYTHON_AI_URL: http://python-ai:8000 ports: - "8080:8080" networks: - smart-doc-net depends_on: mysql: condition: service_healthy rabbitmq: condition: service_healthy frontend: build: ./smart-doc-frontend container_name: smart-doc-frontend restart: unless-stopped ports: - "80:80" networks: - smart-doc-net depends_on: - java-backend - python-ai # ============================================================ # (可选)MinerU 服务 — 取消注释以启用 # ============================================================ # mineru: # image: opendatalab/mineru:latest # container_name: smart-doc-mineru # restart: unless-stopped # environment: # MINERU_MODEL_SOURCE: modelscope # ports: # - "8001:8001" # volumes: # - mineru_models:/root/.cache/modelscope # - mineru_weights:/root/magic-pdf # networks: # - smart-doc-net # # GPU 加速(可选): # # deploy: # # resources: # # reservations: # # devices: # # - driver: nvidia # # count: 1 # # capabilities: [gpu] volumes: mysql_data: rabbitmq_data: minio_data: es_data: etcd_data: milvus_minio_data: huggingface_models: python_temp: # mineru_models: # mineru_weights: ``` 根目录创建 `.env` 文件(不提交 Git): ```bash # .env — 敏感配置,加入 .gitignore LLM_API_KEY=sk-your-api-key LLM_API_BASE=https://api.deepseek.com LLM_MODEL=deepseek-chat ``` 启动全栈: ```bash # 1. 先启动 MinerU(参考上方第二步中的官方文档) # 2. 一键启动全栈 docker-compose up -d # 4. 查看状态 docker-compose ps # 5. 查看日志 docker-compose logs -f python-ai ``` --- ### 基础设施手动部署(不用 Docker 时参考) | 组件 | 端口 | 安装/启动方式 | | --- | --- | --- | | MySQL 8.0 | 3306 | 创建数据库 `xiaoao_doc`,执行初始化 SQL | | RabbitMQ 3.12 | 5672 / 15672 | `rabbitmq-server` 启动 | | MinIO | 9000 / 9001 | `minio server /data --console-address ":9001"` | | Elasticsearch 8.13 | 9200 | 修改 `elasticsearch.yml` 关闭安全认证后启动 | | Milvus 2.4 | 19530 | 需先启动 etcd 和 MinIO,再启动 `milvus run standalone` | | MinerU API | 8001 | `mineru-api --host 0.0.0.0 --port 8001` | ## 核心功能 ### 文档管理 - **上传文档**:支持 PDF、Word 等格式上传,存入 MinIO 对象存储 - **自动解析**:通过 RabbitMQ 异步任务队列,触发 Python AI 服务解析文档 - **解析方案**:优先使用 MinerU(保留表格/公式/排版),不可用时自动降级到 PyMuPDF + PaddleOCR ### AI 智能检索 - **混合检索**:Milvus 向量语义检索 + Elasticsearch BM25 全文检索 → RRF 融合 - **Rerank 精排**:BGE-Reranker 对候选片段重排序 - **RAG 问答**:LangGraph Agent 编排,结合检索上下文调用 LLM 生成答案 - **来源高亮**:PDF 阅读器中高亮定位答案来源坐标 ### PDF 阅读器 - 在线 PDF 渲染(PDF.js) - 搜索结果坐标高亮覆盖层 - 版式分析坐标映射 ## 环境变量参考 | 变量 | 说明 | 默认值 | |------|------|--------| | `LLM_API_KEY` | LLM API 密钥(必需) | — | | `LLM_API_BASE` | LLM API 地址 | `https://api.openai.com/v1` | | `LLM_MODEL` | LLM 模型名 | `gpt-4o-mini` | | `EMBEDDING_MODEL` | Embedding 模型 | `BAAI/bge-large-zh-v1.5` | | `MINIO_ENDPOINT` | MinIO 地址 | `localhost:9000` | | `RABBITMQ_HOST` | RabbitMQ 地址 | `localhost` | | `ES_HOSTS` | Elasticsearch 地址 | `http://localhost:9200` | | `MILVUS_HOST` | Milvus 地址 | `localhost` | 完整配置见 [python_service/config/settings.py](python_service/config/settings.py)。 ## 注意事项 1. **MinIO 初始化**:首次启动后需进入 MinIO Console(`:9001`)创建 `documents` 存储桶 2. **模型下载**:首次运行时会自动从 HuggingFace 下载 Embedding/Reranker 模型;国内用户请设置 `HF_ENDPOINT=https://hf-mirror.com` 3. **MinerU**:高质量 PDF 解析需要 GPU 环境,CPU 环境会自动降级到 PyMuPDF + PaddleOCR 4. **Elasticsearch**:开发环境可设置 `xpack.security.enabled=false` 关闭安全认证 5. **MySQL 初始化**:数据库建表脚本位于 [java_service/src/main/resources/db/](java_service/src/main/resources/db/)