Spaces:
Sleeping
Sleeping
metadata
title: RAG
emoji: 👁
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
RAG Model for Solana SuperTeam Chatbot
Mô hình RAG (Retrieval Augmented Generation) cho Solana SuperTeam Chatbot sử dụng Gemini-1.5-flash và Pinecone để lưu trữ và truy xuất dữ liệu liên quan đến Solana SuperTeam.
Cấu trúc
.
├── NLP_model/
│ └── chatbot.py # Chứa logic của mô hình RAG
├── app.py # FastAPI server
├── requirements.txt # Thư viện cần thiết
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── .dockerignore # Docker ignore file
└── .env # Biến môi trường (API keys)
Cài đặt
Cài đặt trực tiếp
- Cài đặt các thư viện:
pip install -r requirements.txt
- Cấu hình API keys trong file
.env
:
GOOGLE_API_KEY=your_google_api_key
PINECONE_API_KEY=your_pinecone_api_key
- Chạy API:
python app.py
Cài đặt bằng Docker
Đảm bảo đã cài đặt Docker và Docker Compose
Cấu hình API keys trong file
.env
:
GOOGLE_API_KEY=your_google_api_key
PINECONE_API_KEY=your_pinecone_api_key
- Build và chạy container:
docker-compose up --build
API sẽ chạy trên http://localhost:8000
.
API Endpoints
POST /chat
Gửi câu hỏi đến mô hình RAG:
{
"query": "Câu hỏi của người dùng",
"user_id": "id_của_người_dùng"
}
Response:
{
"response": "Câu trả lời từ mô hình RAG"
}
GET /health
Kiểm tra trạng thái của API:
{
"status": "healthy"
}
Lưu ý
- Mô hình sử dụng Pinecone index "testbot768" để lưu trữ và truy xuất thông tin.
- Nếu Pinecone không khả dụng, mô hình sẽ cố gắng sử dụng FAISS local index nếu có.
- Mô hình lưu lịch sử trò chuyện cho mỗi người dùng để cung cấp phản hồi phù hợp với ngữ cảnh.
- Khi sử dụng Docker, các biến môi trường sẽ được tự động load từ file .env.
- Container sẽ tự động restart nếu gặp lỗi hoặc server được khởi động lại.