The Salon Bot is a Python-based application designed to provide an interactive and intelligent conversational experience for customers of a beauty salon. It leverages advanced AI techniques, including Large Language Models (LLMs) and LangGraph, to understand user requests and facilitate salon-related tasks.
- Appointment Booking: Users can book appointments by specifying services, preferred dates, and times.
- Service Inquiries: The bot can provide information about salon services, including details and potential pricing.
- Master Information: Users can inquire about specific masters or general master availability.
- Natural Language Understanding: Utilizes LLMs to understand user queries in natural language, even with complex or multi-part requests.
- Contextual Conversation: Maintains conversation history through
ConversationMemoryto provide relevant and uninterrupted interactions. - Tool Integration: Interacts with external tools to fetch real-time data from a vector store (e.g., Qdrant) for services and master information.
- Observability: Integrates with Langfuse for monitoring, tracing, and analyzing the bot's performance and interactions.
The project follows a layered architecture, with clearly defined responsibilities for each component:
- Main Entry Point (
main.py): Initializes the application, sets up all necessary components (LLM, database managers, tools, agent), and starts the user interaction loop. - Agent (
salon_agent.py): TheSalonAgentorchestrates the conversation flow. It manages the agent's state, integrates with the state graph, and handles memory and dependency management. - State Graph (
salon_graph.py): Implements the conversational logic using LangGraph's stateful execution. It defines nodes for intent detection and request processing, guiding the conversation through different states. - Nodes (
process_request.py,intent_nodes.py):intent_nodes.py: Contains logic for detecting user intents using an LLM and parsing the results.process_request.py: Handles the core business logic based on the detected intent, extracting entities, calling tools, and formulating responses.
- Data Management:
DependencyManager: Manages dependencies, including database and vector store connections.DatabaseManager,QdrantManager,SbertEmbeddingProvider: Handle data persistence and vector storage.ConversationMemory: Manages dialogue history and short-term memory.
- Configuration (
config/): Contains configurations for LLMs (ollama_config), Langfuse (langfuse_config), and application settings (settings). - Tools (
tools/): Defines specific tools the agent can use, such asGetServiceInfoToolandGetMasterInfoTool.
The following environment variables are used to configure the application:
- Langfuse:
LANGFUSE_SECRET_KEY: Secret key for Langfuse authentication.LANGFUSE_PUBLIC_KEY: Public key for Langfuse authentication.LANGFUSE_HOST: Host URL for the Langfuse instance.
- LLM Configuration:
BOT_OLLAMA_HOST: Host URL for the Ollama service.OLLAMA_CHAT_MODEL: The name of the Ollama chat model to use (e.g., "qwen2.5:7b").
- Database Configuration:
DATABASE_URL: The primary connection URL for the PostgreSQL database.DATABASE_MEMORY_URL: A specific connection URL or an in-memory database URL.DB_SCHEMA_NAME: The schema name to use within the database (e.g., "dialog").
- Vector Store Configuration:
QDRANT_URL: Host URL for the Qdrant vector store.
- Other Configurations:
HG_FACE_TOKEN: Hugging Face API token, potentially for accessing models or datasets.MCP_SERVER_COMMAND: Command to run the MCP server.MCP_SERVER_ARGS: Arguments for the MCP server (commented out, likely for production use).
- Python: The primary programming language.
- LangGraph: For building and managing stateful, multi-agent applications.
- LLMs: Utilizes models through Ollama for natural language understanding and generation.
- Qdrant: A vector database used for efficient similarity search on embeddings.
- Langfuse: For observability, tracing, and analytics.
- Pydantic: For data validation and defining state models.
- The user inputs a message.
- The
SalonAgentreceives the message. - The
detect_intent_nodeuses an LLM to determine the user's intention and extract relevant entities. - The
process_requestnode takes the intent and message, retrieves necessary information using tools, and decides the next action (e.g., asking for clarification, providing information, or confirming a booking). - The conversation state is updated, and the response is sent back to the user.
- The
ConversationMemoryand database managers ensure that the conversation context is maintained and persisted.