LLM-powered AI support chatbot with FastAPI, RAG, and vector database. Production-ready implementation with Docker, tests, and CI/CD pipeline.
- LLM Integration: Support for OpenAI API, HuggingFace, or local LLMs
- RAG (Retrieval-Augmented Generation): Vector database (FAISS/Chroma) for semantic search
- FastAPI Server: RESTful API for chat interactions
- Docker & Docker Compose: Easy deployment and scaling
- Unit & Integration Tests: Comprehensive test coverage with pytest
- GitHub Actions CI/CD: Automated testing and deployment pipeline
- Logging & Monitoring: Structured logging and error handling
ai-support-chatbot/
├── src/
│ ├── main.py # FastAPI application
│ ├── llm_service.py # LLM integration (OpenAI, HuggingFace)
│ ├── vectordb.py # Vector database (FAISS/Chroma)
│ ├── schemas.py # Pydantic models for validation
│ └── config.py # Configuration & environment variables
├── tests/
│ ├── test_llm_service.py
│ ├── test_vectordb.py
│ └── test_api.py
├── config/
│ ├── prompts.yaml # LLM prompts & system messages
│ └── .env.example
├── Dockerfile
├── docker-compose.yml # PostgreSQL for chat history
├── requirements.txt
├── .gitignore
├── .github/workflows/
│ └── test.yml # CI/CD pipeline
└── README.md
- Python 3.10+
- Docker & Docker Compose (for containerized setup)
- OpenAI API key (or local LLM setup)
# Clone the repository
git clone https://github.com/Cyb3rFake/ai-support-chatbot.git
cd ai-support-chatbot
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Copy example environment file
cp config/.env.example .env
# Edit .env with your OpenAI API key
echo "OPENAI_API_KEY=your_api_key_here" >> .env# Start the FastAPI server
uvicorn src.main:app --reload --host 0.0.0.0 --port 8000# Build and start containers
docker-compose up --build
# The API will be available at http://localhost:8000curl -X POST "http://localhost:8000/api/chat" \
-H "Content-Type: application/json" \
-d '{"message": "How do I reset my password?"}'{
"session_id": "uuid-1234",
"message": "How do I reset my password?",
"response": "You can reset your password by...",
"confidence": 0.92,
"source_documents": ["faq_001.txt", "help_page_05.txt"]
}# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=html
# Run specific test file
pytest tests/test_llm_service.py -vGitHub Actions automatically:
- Runs tests on every push
- Checks code quality (flake8, black)
- Builds Docker image
- Publishes test results
from src.llm_service import OpenAILLM
llm = OpenAILLM(api_key="sk-...")
response = llm.generate("What is AI?", temperature=0.7)from src.llm_service import LocalLLM
llm = LocalLLM(model="llama2", base_url="http://localhost:11434")
response = llm.generate("What is AI?")from src.llm_service import HuggingFaceLLM
llm = HuggingFaceLLM(model_name="gpt2")
response = llm.generate("What is AI?")from src.vectordb import VectorDB
db = VectorDB()
ddb.add_documents(["FAQ.pdf", "help_guide.md"])
db.save("./data/vectorstore")results = db.search("password reset", top_k=3)
for doc, score in results:
print(f"{doc}: {score}")User Input
|
v
[FastAPI Endpoint]
|
v
[Vector Search] --> [Retrieve Relevant Documents]
|
v
[LLM Prompt Building] --> [Combine context + user query]
|
v
[LLM Generation] --> [Stream response]
|
v
[Response Formatting] --> [JSON response + metadata]
|
v
[Database Logging] --> [Store conversation history]
|
v
[Return to User]
- Latency: <2s for typical queries (with caching)
- Throughput: 100+ concurrent users
- Accuracy: 90%+ relevance with proper fine-tuning
- Fine-tuning on domain-specific data
- Multi-language support
- Real-time conversation analytics
- Feedback loop for continuous improvement
- Advanced caching strategies
- A/B testing framework
Pull requests are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details
Cyb3rFake - Junior ML Engineer
- GitHub: @Cyb3rFake
- Interests: LLMs, MLOps, AI Automation
For issues, questions, or suggestions, please open an issue on GitHub.