鸡尾酒推荐系统
一个基于Python的鸡尾酒推荐系统,使用带有向量嵌入的RAG(检索增强生成)和Pinecone进行智能鸡尾酒建议。该系统与LMStudio集成,用于本地语言模型推理。
特性
- 🍹 鸡尾酒数据管理和搜索
- 🔍 基于向量的嵌入相似度搜索
- 🌲 松果矢量数据库集成
- 🤖 RAG(检索增强生成)用于智能推荐
- 🖥️ LMStudio集成用于本地LLM推理
- 📊 全面的日志记录和错误处理
- 🧪 全面测试覆盖
项目结构
├── cocktail_server.py # Main server application
├── config/
│ └── logger.py # Logging configuration
├── data/
│ └── cocktail_dataset.json # Cocktail database
├── models/
│ ├── cocktail.py # Cocktail data model
│ └── ingredient.py # Ingredient data model
├── services/
│ ├── cocktail_data_service.py # Cocktail data operations
│ ├── embedding_service.py # Vector embedding generation
│ ├── pinecone_service.py # Pinecone vector DB operations
│ └── rag_service.py # RAG implementation
├── tests/ # Unit tests
└── logs/ # Application logs先决条件
- Python 3.13(但之前的版本可能适用)
- LMStudio已安装并正在运行
- Pinecone帐户、API密钥和创建的索引
安装
- 克隆存储库:
git clone
cd
- 创建Anaconda环境:
conda create -n cocktail-env python=3.13 -y
conda activate cocktail-env- 安装依赖项:
pip install -r requirements.txt- 设置环境变量:
cp .env.example .env编辑 .env 使用您的配置文件:
data_path=your/path/to/cocktail_dataset.json
embedding_model=your_embedding_model_here
embedding_dimension=your_embedding_dimension_here
pinecone_index_name=your_pinecone_index_name_here
PINECONE_API_KEY=your_pinecone_api_key_hereLMStudio集成设置
- 安装LMStudio:
- 下载自 https://lmstudio.ai/ - 安装并启动应用程序
- 下载模型:
- 打开LMStudio - 浏览并下载合适的模型 - 鸡尾酒推荐模型: - qwen3-8b
- 集成MCP
- 在LMStudio中,转到设置->程序->安装->编辑mcp.json - 在那里添加以下json:
{
"mcpServers": {
"cocktail-mcp": {
"command": "C:/path/to/your/environment/python.exe",
"args": ["c:\\path\\to\\cocktail_server.py"]
}
}
}_用法_
- 只需在LMStudio界面聊天,并询问鸡尾酒推荐!
运行测试
执行测试套件:
# Run all tests
python -m pytest tests/
# Run specific test file
python -m pytest tests/test_rag_service.py日志
检查应用程序日志 logs/ 目录:
tail -f logs/cocktail_app.log