ShoppingGPT is an AI-powered intelligent shopping assistant that combines advanced natural language processing techniques to deliver a smart and seamless shopping experience. Built with a focus on performance, scalability, and user experience, ShoppingGPT integrates cutting-edge technologies to revolutionize e-commerce interactions.
- ๐ง Large Language Models (LLMs): Leverages the power of Google's Gemini model for natural, context-aware conversations.
- ๐ RAG (Retrieval-Augmented Generation): Enhances responses with relevant product information from SQLite database, ensuring accurate and up-to-date product details.
- ๐ฃ๏ธ Semantic Router: Intelligently routes queries to the appropriate handling mechanism using advanced embedding techniques.
- ๐ Advanced Product Search: Utilizes case-insensitive and partial matching capabilities, powered by efficient SQLite queries and indexing.
- ๐ฌ Intelligent Chatbot Interface: User-friendly chat interface designed for intuitive product queries and personalized recommendations.
ShoppingGPT employs a modular, scalable architecture:
-
User Interface (Flask Web App)
- Handles user input and displays responses
-
Semantic Router
- Utilizes GoogleGenerativeAIEmbeddings
- Classifies and routes user queries to appropriate handlers
-
Query Handlers a. Chitchat Chain
- Manages general conversation
- Leverages LLM (Gemini-1.5-flash) and ConversationBufferMemory
b. Shopping Agent
- Processes product-related queries
- Employs various tools:
- Product Search Tool (SQLite-based)
- Policy Search Tool (FAISS-based)
-
Data Storage
- SQLite database for product information
- FAISS vector store for policy information
-
External Services
- Google Generative AI API for LLM and embeddings
This architecture enables efficient query routing, context-aware responses, and seamless integration of product and policy information into the conversation flow.
- RAG System: Combines FAISS vector store for policy information and SQLite for product data, ensuring fast and relevant information retrieval.
- LLM Integration: Utilizes
ChatGoogleGenerativeAI
with the Gemini-1.5-flash model to generate human-like responses. - Product Search: Implements a robust
ProductDataLoader
class for efficient SQLite query execution and result formatting. - Policy Search: Uses FAISS for fast similarity search on company policies and guidelines.
ShoppingGPT utilizes advanced routing and classification techniques to enhance its performance:
-
Semantic Router: We implement the Semantic Router library for efficient query routing. This allows for superfast decision-making and intelligent processing of multi-modal data.
-
Cosine Similarity: The system employs cosine similarity algorithm to measure the semantic similarity between user queries and predefined routes, ensuring accurate classification and routing.
-
Custom Hugging Face Model: We use a fine-tuned Hugging Face model specifically trained for classifying text as either chitchat or product-related. This model enhances the accuracy of query classification.
The text classification model used in this project is available on Hugging Face:
This model is used for classifying user queries and enhancing the overall performance of ShoppingGPT. Feel free to explore and use it in your own projects!
Product data is stored in SQLite and includes the following fields:
product_code
: Unique identifier (TEXT)product_name
: Name of the product (TEXT)material
: Material composition (TEXT)size
: Available sizes (TEXT)color
: Available colors (TEXT)brand
: Manufacturer or seller (TEXT)gender
: Target gender (TEXT)stock_quantity
: Quantity in stock (INTEGER)price
: Product price (REAL)
To set up ShoppingGPT:
-
Clone the repository:
git clone https://github.com/yourusername/ShoppingGPT.git cd ShoppingGPT
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment: Create a
.env
file in the root directory:GOOGLE_API_KEY=your_google_api_key
-
Initialize the database:
python scripts/init_db.py
To start ShoppingGPT:
-
Run the Flask application:
python app.py
-
Access the chatbot: Open your web browser and navigate to
http://localhost:5000
. -
Interact with ShoppingGPT:
- Ask about products: "What red shirts do you have in stock?"
- Inquire about policies: "What's your return policy?"
- General chat: "How's the weather today?"
Our user-friendly chat interface
Example of product search results
Friendly conversation with our AI assistant
These images showcase the key aspects of our ShoppingGPT project. From the intuitive chat interface to the powerful product search and easy access to policy information, our AI assistant is designed to enhance your shopping experience! ๐๏ธ๐ค
To customize ShoppingGPT for your specific needs:
- Update product database: Modify
data/products.db
with your inventory. - Adjust policies: Edit
data/policy.txt
with your company's guidelines. - Fine-tune responses: Modify prompt templates in
shoppinggpt/tool/product_search.py
andshoppinggpt/tool/policy_search.py
.
If you encounter any issues:
- Ensure all environment variables are correctly set.
- Check the console for any error messages.
- Verify that the database and policy files are in the correct locations.
- Make sure all required dependencies are installed correctly.
- Confirm that you're using a compatible Python version (3.7+).
For more detailed information, please refer to the documentation or open an issue on the GitHub repository.
We welcome contributions to ShoppingGPT! Here's how you can help:
- Fork the repository
- Create a new branch (
git checkout -b feature/AmazingFeature
) - Make your changes
- Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the project's coding standards.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to all contributors who have helped shape ShoppingGPT
- Special thanks to the open-source community for providing amazing tools and libraries
Happy shopping with ShoppingGPT! ๐๏ธ๐ค