# LocalRAG **Repository Path**: kjhhhh/local-rag ## Basic Information - **Project Name**: LocalRAG - **Description**: 本地部署的RAG问答系统 - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-02-05 - **Last Updated**: 2026-05-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 基于本地 md/txt 文档、FAISS 和 OpenAI 兼容模型接口的最小 RAG 问答系统。 # 环境变量 OPENAI_API_KEY=your_api_key \ OPENAI_BASE_URL=https://your-openai-compatible-api/v1 \ EMBEDDINGS_MODEL=text-embedding-3-large \ CHAT_MODEL=gpt-3.5-turbo \ CHUNK_SIZE=200 \ CHUNK_OVERLAP=10 \ TOP_K=5 # 目录结构 - app/main.py:FastAPI 接口入口 - app/routers/:HTTP 路由层 - app/services/:文档、索引、问答服务层 - app/schemas/:请求和响应模型 - app/utils/:文件校验和路径工具 - data/:原始文档目录 - indexes/:FAISS 索引目录 - requirements.txt:依赖列表 # 安装依赖 pip install -r requirements.txt # 启动 FastAPI python -m fastapi dev app/main.py # 使用 curl 测试 curl -X POST "http://127.0.0.1:8000/documents/knowledge_base.md/chat" \ -H "Content-Type: application/json" \ -d "{\"q\": \"What is this document about?\"}" 返回示例: { "docname": "knowledge_base.md", "answer": "...", "sources": [ { "content": "...", "source": "D:/LocalRAG/data/knowledge_base.md" } ] } - 当前支持本地 `.md`、`.txt`、`.pdf` - 提供文档上传、列表、删除、建索引和单文档问答接口