How unicamp-dl/retailgpt works
Project type and purpose
• This is a full-stack, microservice-style chatbot application (“Retail-GPT”) built to deliver a RAG-powered conversational sales agent.
• It consists of four discrete services:
• A Streamlit chat interface (“chat_interface”)
• A Rasa core NLP/chatbot server (“rasa_chatbot”)
• A Rasa actions server hosting custom actions and the RAG subsystem (“actions_server”)
• A Redis database for session/cart storage
File structure
• Top-level:
• docker-compose.yml: orchestrates all containers
• chat_interface/: front end
• retailGPT/rasa_chatbot/: Rasa core
• retailGPT/actions_server/: Rasa custom actions + RAG
• retailGPT/datasets/: static/evaluation data
• Within actions_server/src/LLMChatbot/services: micro-services handling database, product retrieval, cart/memory, guardrails, and llm calls.
README for additional insights
• Rasa server handles intents, NLU, entity extraction, dialogue policies, and forwards “action” requests to actions_server.
• actions_server implements:
• A “cart_handler” to maintain shopping cart in Redis
• A “memory_handler” for conversation context (also Redis)
• A “product_handler” pulling product info from JSON datasets
• A “llm_handler” that issues OpenAI GPT-4o function calls
• Guardrails enforcement
• chat_interface communicates via HTTP to rasa_chatbot endpoints.
Main components & their relationships
a. Components:
• Client/UI: Streamlit app
• Rasa Core server: NLU + dialogue management
• Rasa Actions server: custom actions + RAG logic
• Redis: tracker store & cart store
• External LLM API: OpenAI (GPT-4o)
• Static datasets: JSON product definitions, evaluation sets
b. Interactions/data flow:
1. UI → Rasa Core (REST endpoint)
2. Rasa Core: intent classification → slot filling → policy → if custom action → HTTP → Actions server
3. Actions server:
– fetch conversation state/cart from Redis
– call product/memory handlers as needed
– call llm_handler → OpenAI API → receive function calls → dispatch to local services (e.g., cart_handler)
– save updated state in Redis
4. Actions server → HTTP response back to Rasa Core → Rasa orchestrates next reply → UI
c. Architectural patterns:
• Microservices for separation of concerns (UI, NLU, actions, storage)
• Function-call pattern with GPT for external tool integration
• Event-driven/custom-action pattern in Rasa
• Redis as a distributed in-memory store for session/cart
d. Key technologies:
• Streamlit (UI)
• Rasa (NLU & Core)
• Python-based Rasa SDK for actions
• OpenAI API (GPT-4o)
• Redis (via Docker compose)
• Docker & Docker-Compose