An intelligent shopping assistant that helps users find products with natural language queries and provides personalized recommendations. Built with Python and Typesense, this chatbot-style application offers an engaging shopping experience with smart product suggestions and styling tips.
- 🗣️ Natural Language Understanding: Ask for products in everyday language
- 🎯 Smart Product Search: Finds relevant items based on your requirements
- 👔 Style Recommendations: Get personalized styling tips for products
- 🎨 Color Matching: Understands color relationships and combinations
- 💡 Alternative Suggestions: Offers similar options when exact matches aren't found
- 💬 Interactive Experience: Engaging chatbot-style interface with Rich text formatting
- Python 3.8+
- Typesense Server
- OpenAI API Key
- Clone the repository:
git clone https://github.com/thakurcoderz/ai-powered-shopping-assistant.git
cd ai-powered-shopping-assistant- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Copy the example environment file and update with your credentials:
cp .env.example .env- Update
.envwith your API keys:
OPENAI_API_KEY=your-openai-api-key-here
TYPESENSE_API_KEY=your-typesense-api-key-here
TYPESENSE_HOST=localhost
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http- Start the interactive demo:
python product_recommendation_agent.py interactive- Or run with example queries:
python product_recommendation_agent.pyTry asking things like:
- "Show me comfortable walking shoes"
- "I need a casual outfit for work"
- "Find me a warm winter jacket"
- "Something light colored to go with dark jeans"
Example response:
📦 Found 3 items that match your request:
--------------------------------------------------
1. **Product Name** - $Price
✓ Color: Color
✓ Material: Material
✓ Category: Category
✓ Stock: X available
==================================================
Additional Information:
==================================================
👔 STYLING TIP:
[Personalized styling advice]
🔄 ALTERNATIVE OPTIONS:
[Similar product suggestions]
❓ WHAT'S NEXT:
[Follow-up question]
The system uses a multi-agent architecture with specialized agents:
-
Query Interpreter Agent:
- Analyzes natural language queries
- Extracts search parameters
- Handles ambiguous requests
- Uses GPT-4.1-nano model
-
Search Refinement Specialist:
- Improves search results
- Applies intelligent filters
- Tracks search iterations
- Uses GPT-4.1-nano model
-
Result Quality Evaluator:
- Assesses result relevance
- Scores product matches
- Suggests improvements
- Uses GPT-4.1-nano model
-
Product Search Specialist:
- Executes precise searches
- Manages faceted search
- Handles price ranges
- Uses GPT-4.1-nano model
-
Product Recommendation Expert:
- Coordinates other agents
- Provides final recommendations
- Adds styling tips
- Uses GPT-4.1-nano model
This multi-agent architecture ensures:
- Specialized processing at each step
- Quality control throughout the pipeline
- Efficient coordination between components
- Comprehensive product recommendations
-
Product Model:
class Product(BaseModel): product_id: Optional[str] product_name: Optional[str] price: Optional[float] category: Optional[str] sub_category: Optional[str] color: Optional[str] material: Optional[str] gender: Optional[str] size: Optional[str] description: Optional[str] keywords: Optional[str] quantity_in_stock: Optional[int] relevance_score: Optional[float]
-
ProductRecommendation Model:
class ProductRecommendation(BaseModel): greeting: str products: List[Product] reasoning: str total_found: int confidence_score: float styling_tip: str follow_up_question: str alternative_suggestions: str
-
Smart Search Logic:
- Semantic understanding of queries
- Color and style matching
- Category-aware search
- Price range consideration
-
Recommendation System:
- Personalized product suggestions
- Style compatibility analysis
- Alternative recommendations
- Contextual follow-up questions
-
User Experience:
- Rich text formatting
- Clear product presentations
- Helpful styling tips
- Interactive refinement options
The product collection should have the following fields:
product_id: stringproduct_name: stringprice: floatcategory: stringsub_category: stringcolor: stringmaterial: stringgender: stringdescription: stringkeywords: stringquantity_in_stock: int
Required environment variables:
OPENAI_API_KEY: Your OpenAI API keyTYPESENSE_API_KEY: Your Typesense API keyTYPESENSE_HOST: Typesense server hostTYPESENSE_PORT: Typesense server portTYPESENSE_PROTOCOL: HTTP/HTTPS
- OpenAI for the GPT-4.1-nano model
- Typesense for the search engine
- Rich library for beautiful terminal formatting
