This project implements a multi-agent customer support system that simulates a customer service representative named "Frodo". The system intelligently routes customer inquiries to specialized backend agents while maintaining a seamless, unified conversation interface.
- Architecture
- Features
- Tech Stack
- Project Structure
- Setup Instructions
- Running the Application
- Implementation Details
The system implements a multi-agent architecture with the following key components:
- Streamlit Interface + Persona (Frodo):
- Provides the user interface
- Acts as the single point of contact for customers
- Manages conversation flow and state
- Specialized Agents:
- Product Details Agent: Handles product specifications and comparisons
- Product Reviews Agent: Manages customer reviews and feedback
- Orders Agent: Processes orders and tracks status
- Vector Databases: Using pgvector for efficient similarity search
- SQLite Database: For order management
- Knowledge Base: Built from product catalog and reviews PDF documents
- Provides comprehensive product information
- Answers queries about specific product features
- Performs product comparisons
- Handles natural language queries about product capabilities
- Retrieves and presents existing product reviews
- Handles review-related queries
- Filters reviews based on rating/sentiment
- Supports adding new reviews for purchased products
- Processes new product orders
- Provides real-time order status updates
- Manages order-related inquiries
- Handles shipping and delivery tracking
- Context-based conversation routing
- Seamless agent transitions
- Consistent persona maintenance
- Agent enable/disable functionality
- Error handling with persona-maintained responses
- Application Framework: Streamlit (for both UI and application logic)
- Databases:
- PostgreSQL with pgvector extension (for vector storage)
- SQLite (for order management)
- AI/ML:
- OpenAI GPT-4o for conversation
- OpenAI Embeddings for vector search
- Docker: For containerization and deployment
- Vector Search: pgvector for similarity search
- Core Libraries:
- phi for agent framework and knowledge base management
- SQLAlchemy for database operations
.
├── Dockerfile
├── data/
│ ├── SWE-GenAI_Take_Home/
│ │ ├── Sleep_Better_Product_Catalog.pdf
│ │ └── Sleep_Better_Product_Reviews.pdf
│ └── db/
│ └── orders.sqlite
├── docker-compose.yml
├── requirements_env.txt
└── src/
├── agents/
│ ├── main_agent.py
│ └── orders_agent.py
├── config/
│ └── settings.json
├── db/
│ ├── models/
│ │ └── order.py
│ └── orders.py
├── interface/
│ └── app.py
└── tools/
└── order_manager.py
- Docker and Docker Compose
- Clone the repository:
git clone https://github.com/abojja9/sleep-better-ai
cd sleep-better-ai- Create
.envfile:
cp .env.example .envThe application uses two databases:
- PostgreSQL with pgvector (via Docker)
- SQLite for order management (auto-created)
Both databases are automatically initialized when running with Docker.
docker-compose up --buildThe application will be available at: http://localhost:8502
For development purposes only:
streamlit run src/interface/app.pyNote: This requires setting up PostgreSQL with pgvector extension manually.
-
Vector Databases (pgvector):
- Stores embeddings for product details and reviews
- Enables semantic search capabilities
- Supports hybrid search (vector + keyword)
-
Knowledge Base:
- Built from PDF documents
- Automatically chunked and embedded
- Supports incremental updates
-
Agent System:
- Context-aware routing
- Maintains conversation history
- Handles agent state management
- Supports agent enabling/disabling
-
Order Management:
- SQLite database for order tracking
- Supports CRUD operations
- Handles order status updates
- Manages customer information
- API keys managed via environment variables
- Database credentials secured
- Input validation and sanitization
- Error handling with appropriate logging



