RecAgent is a containerized FastAPI application implementing a cognitive-neuroscience-inspired consumer agent framework for the BCT Hackathon. It uses LangGraph for reasoning, ChromaDB for tri-layer memory, and web search for real-time economic context.
- Tri-Layer Memory Module:
- Sensory Memory: Rapidly processes raw environmental and product data.
- Short-term Memory: Manages session context and recurring theme identification.
- Long-term Memory (ChromaDB): Persists abstract insights and past behaviors with a mathematical forgetting mechanism.
- Product Discovery Modes:
- Offline Mode: Searches a local vector database of products (no internet).
- Online Mode: Uses real-time web search with neutral queries, manually filtered by the LLM.
- Multi-Source Catalog: Supports multiple datasets (Amazon, Jumia, Local Store) with the ability to filter per request.
- Dynamic Reasoning Loop:
- Fetches real-time country-specific economic indicators (Inflation, PPI, Exchange Rates).
- LLM-based reasoning engine that weighs personal income against localized economic reality.
- Multi-Task Endpoints:
- Reviews: Generates localized Nigerian reviews and ratings for specific products.
- Recommendations: Generates personalized product recommendations based on persona interests.
- LangChain / LangGraph: Orchestration and state management.
- FastAPI: RESTful API layer.
- ChromaDB: Vector database for memory and product catalog.
- HuggingFace Local Embeddings:
all-MiniLM-L6-v2for semantic similarity. - Gemini: Large Language Model for complex reasoning.
- DuckDuckGo Search: Real-time web data fetching (Online mode).
- Docker and Docker Compose.
- Google Gemini API Key (or an Ollama instance).
-
Clone the repository:
git clone https://github.com/matt-wisdom/BCTHack cd dsn-rec-agent -
Configure Environment Variables: Create a
.envfile based on.env.example. -
Pre-download Models & Initialize DB:
uv run python download_models.py
-
Seed Product Catalog: Place your CSV files in
dsn-rec-agent/dataset/and run:uv run python seed_catalog.py
-
Run with Docker Compose:
docker-compose up --build
POST /reviews/simulate
Payload:
{
"persona_text": "A 28-year-old tech enthusiast from Lagos...",
"product_text": "Samsung Galaxy S24 Ultra...",
"mode": "offline", # Optional
"dataset_source": "store" # Optional
}POST /recommendations/generate
Payload:
{
"persona_text": "A price-conscious student who loves photography...",
"mode": "offline", # Optional
"dataset_source": "all" # Optional
}- Forgetting Mechanism: Implemented in
app/memory.pyusing a power function to balance recency and importance. - Dataset Sources: Options include
all,amazon,jumia, andstore.