Skip to content

This AI Agent follows the best RAG practices to help E-commerce businesses solve their Customer Support Queries.

License

Notifications You must be signed in to change notification settings

HopMaster03/E-Commerce-Support-Agent-RAG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

E-COMMERCE-SUPPORT-AGENT-RAG

Empowering Commerce with Conversational AI Precision

license last-commit repo-top-language repo-language-count


πŸ”— Table of Contents


πŸ“ Overview

The E-Commerce-Support-Agent-RAG project provides a comprehensive understanding of the working behind a Customer Service Agent for online retailers by utilizing advanced AI to provide dynamic, personalized support by implementing Adaptive RAG.
Adaptive RAG is a method that chooses the best strategy for answering questions, from a direct LLM response to single or multiple retrieval steps. This selection is based on the query’s complexity, as determined by a classifier. The 2 strategies for answering are:

  • Single-Step Retrieval: For moderately complex questions, it retrieves information from a single external source, ensuring the answer is both swift and well-informed.
  • Multi-Step Retrieval: For highly complex questions, it consults multiple sources, piecing together a detailed and comprehensive answer.

This system efficiently processes and responds to customer inquiries, ensuring a seamless QA experience. Ideal for e-commerce platforms seeking to enhance customer interaction and satisfaction, it leverages machine learning to handle queries with precision and speed.

πŸ‘Ύ Features

Feature Summary
βš™οΈ Architecture
  • Utilizes a modular approach with separate components for handling different functionalities such as user interaction, data management, and response generation.
  • Employs ChromaDB for efficient management and indexing of embedding data.
  • Integrates AI-driven response generation using LiteLLM.
πŸ”© Code Quality
  • Code is organized into logical modules such as app.py, rag/, and agent/ for clarity and maintainability.
  • Uses Pydantic for data validation and schema management, enhancing code reliability.
  • Adheres to Pythonic standards for readability and maintainability.
πŸ“„ Documentation
  • Documentation includes detailed comments within code files explaining the purpose and functionality of each component.
  • Provides comprehensive setup instructions using pip and requirements.txt.
  • Usage and test commands are clearly documented for easy setup and testing.
πŸ”Œ Integrations
  • Integrates with ChromaDB for data storage and retrieval.
  • Uses LiteLLM for AI and machine learning capabilities.
  • Environment variables managed through python-dotenv for secure configuration.
🧩 Modularity
  • Highly modular design with clear separation of concerns among components like EmbeddingService, SupportAgent, and utility modules.
  • Allows easy extension or modification of individual components without affecting others.
  • Modular structure supports scalable development and maintenance.
⚑️ Performance
  • Optimized data handling and response generation for real-time user interaction.
  • Efficient embedding storage and retrieval with ChromaDB.
  • Batch processing capabilities in EmbeddingService enhance performance for multiple texts.
πŸ›‘οΈ Security
  • Uses environment variables for secure API key management.
  • Secure data handling and processing practices are implied through the use of Pydantic models.
  • No explicit security vulnerabilities mentioned, but standard security practices are assumed.

πŸ“ Project Structure

└── E-Commerce-Support-Agent-RAG/
    β”œβ”€β”€ LICENSE
    β”œβ”€β”€ README.md
    β”œβ”€β”€ agent
    β”‚   β”œβ”€β”€ support_agent.py
    β”‚   └── utils.py
    β”œβ”€β”€ app.py
    β”œβ”€β”€ chainlit.md
    β”œβ”€β”€ config
    β”‚   └── settings.py
    β”œβ”€β”€ data
    β”‚   β”œβ”€β”€ knowledge_base
    β”‚   β”œβ”€β”€ loaders
    β”‚   └── processors
    β”œβ”€β”€ llm
    β”‚   β”œβ”€β”€ litellm_service.py
    β”‚   └── prompt_templates.py
    β”œβ”€β”€ models
    β”‚   └── schema.py
    β”œβ”€β”€ rag
    β”‚   β”œβ”€β”€ embedding_service.py
    β”‚   └── vector_store.py
    └── requirements.txt

πŸ“‚ Project Index

E-COMMERCE-SUPPORT-AGENT-RAG/
__root__
app.py - App.py serves as the entry point for a customer support chat application, initializing the support agent and handling user queries
- Upon starting a chat, it loads and indexes necessary data, displays initialization status, and sends a welcome message
- It processes incoming messages and generates responses using a support agent, ensuring a dynamic and interactive user experience.
requirements.txt - Requirements.txt specifies the necessary Python packages for the project, ensuring consistent environments across different setups
- It includes libraries for AI operations, database interactions, environment variable management, numerical computations, and testing
- This setup is crucial for maintaining project functionality and compatibility, facilitating development and deployment processes.
rag
vector_store.py - ChromaVectorStore serves as a wrapper for ChromaDB, facilitating the storage of pre-generated embeddings in a specified collection using an ephemeral client
- It supports adding embeddings along with optional texts, metadata, and custom IDs, generating UUIDs for documents when IDs are not provided
- This component enhances the project's capability to manage and index large volumes of embedding data efficiently.
embedding_service.py - EmbeddingService in `rag/embedding_service.py` manages the generation of text embeddings using the LiteLLM library, configured with specific API keys and model settings
- It supports batch processing for multiple texts and handles individual queries, providing a scalable solution for embedding generation within the project's architecture.
agent
support_agent.py - SupportAgent in `agent/support_agent.py` orchestrates customer interactions for an e-commerce platform by leveraging machine learning models to process and respond to user queries
- It initializes services for data loading, text processing, and embedding generation, and handles query classification, context generation, and personalized customer responses based on the nature of the inquiry.
utils.py - Agent/utils.py serves as a utility module within the broader codebase, primarily handling the parsing of responses from language models and JSON files into structured Pydantic models
- It facilitates the extraction and transformation of data into a format that supports further processing and integration within the application's architecture.
config
settings.py - Config/settings.py establishes the environment for accessing API keys and configuring models within the software architecture
- It initializes settings for embedding and language models, defines parameters for data retrieval, and sets agent behavior controls, ensuring the application interacts effectively with external AI services and manages data processing efficiently.
llm
prompt_templates.py - The `prompt_templates.py` in the `llm` directory defines structured templates for handling customer support queries, specifically focusing on extracting and responding to order-related information
- It categorizes queries into general knowledge requests and specific customer order data, ensuring responses are tailored and relevant based on the explicit details requested by the customer.
litellm_service.py - LiteLLMService in llm/litellm_service.py serves as the interface for generating responses using a language model
- It initializes with API and model settings, and offers a method to produce text outputs based on user prompts and optional system messages, handling errors gracefully during the process.
models
schema.py - Defines data models essential for managing product and order information within the system
- Models such as Product, OrderDetails, and CustomerDetails facilitate structured data storage and retrieval for order processing and customer management, enhancing the system's ability to handle e-commerce transactions efficiently.

πŸš€ Getting Started

βš™οΈ Installation Guide

Install E-Commerce-Support-Agent-RAG using one of the following methods:

Build from source:

  1. Clone the E-Commerce-Support-Agent-RAG repository:
❯ git clone https://github.com/HopMaster03/E-Commerce-Support-Agent-RAG
  1. Navigate to the project directory:
❯ cd E-Commerce-Support-Agent-RAG
  1. Install the project dependencies:

Using pip Β 

❯ pip install -r requirements.txt
  1. Setup .env file
❯ OPENAI_API_KEY = "your API key here"

πŸ€– Usage

Run E-Commerce-Support-Agent-RAG using the following command: Using pip Β 

❯ chainlit run app.py -w

πŸ“Œ Project Roadmap

  • Task 1: Adaptive RAG
  • Task 2: Enabling conversation history & caching.
  • Task 3: Metadata Filtering.

πŸ”° Contributing

  • πŸ’¬ Join the Discussions: Share your insights, provide feedback, or ask questions.
  • πŸ› Report Issues: Submit bugs found or log feature requests for the E-Commerce-Support-Agent-RAG project.
  • πŸ’‘ Submit Pull Requests: Review open PRs, and submit your own PRs.
Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/HopMaster03/E-Commerce-Support-Agent-RAG
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph


πŸŽ— License

This project is protected under the MIT-LICENSE License. For more details, refer to the LICENSE file.


πŸ™Œ Acknowledgments

  • List any resources, contributors, inspiration, etc. here.

About

This AI Agent follows the best RAG practices to help E-commerce businesses solve their Customer Support Queries.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages