MCP - 带有 RAG 的问答系统
MCP 是一种先进的问答系统,使用检索增强生成 (RAG) 技术根据文档集提供准确且符合上下文的答案。
特征
- 🔍 文档中的语义搜索
- 💾 使用 Redis 进行智能缓存
- 📊 使用 MongoDB 进行持久存储
- 🤖 与 OpenAI 集成,用于嵌入和文本生成
- 📈 系统监控和指标
- 🔄 异步操作管理
先决条件
- Python 3.9+
- MongoDB 社区版
- Redis
- OpenAI API 密钥
设施
- 克隆存储库:
git clone https://github.com/votre-username/mcp.git
cd mcp
- 安装系统依赖项:
# MongoDB
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
# Redis
brew install redis
brew services start redis
- 配置Python环境:
python -m venv .venv
source .venv/bin/activate # Sur Unix/macOS
pip install -r requirements.txt
- 配置环境变量:
cp .env.example .env
# Éditer .env avec vos configurations
快速使用
from src.rag import RAGWorkflow
# Initialisation
rag = RAGWorkflow()
# Ingestion de documents
await rag.ingest_documents("chemin/vers/documents")
# Interrogation
response = await rag.query("Votre question ici ?")
文档
测试
python -m pytest tests/ -v
项目结构
mcp/
├── src/
│ ├── __init__.py
│ ├── rag.py # Workflow RAG principal
│ ├── models.py # Modèles de données
│ ├── mongo_operations.py # Opérations MongoDB
│ ├── redis_operations.py # Opérations Redis
│ └── database.py # Configuration de la base de données
├── tests/
│ ├── __init__.py
│ ├── test_mcp.py
│ └── test_mongo_integration.py
├── prompts/
│ ├── system_prompt.txt
│ ├── query_prompt.txt
│ └── response_prompt.txt
├── docs/
│ ├── installation.md
│ ├── usage.md
│ ├── architecture.md
│ └── api.md
├── requirements.txt
├── .env.example
└── README.md
贡献
- 分叉项目
- 为你的功能创建一个分支(
git checkout -b feature/AmazingFeature
) - 提交您的更改(
git commit -m 'Add some AmazingFeature'
) - 推送到分支(
git push origin feature/AmazingFeature
) - 打开拉取请求
执照
该项目已获得 MIT 许可。有关详细信息,请参阅LICENSE文件。
接触
您的姓名 - @your_twitter
项目链接: https://github.com/your-username/mcp