This project demonstrates a simple chatbot for Best Buy customer service using Autogen for conversation generation and Mem0 for memory management.
The bestbuy_basic.py
script creates a context-aware chatbot that can answer customer queries based on previous interactions. It utilizes two main libraries:
- Autogen: For generating AI responses
- Mem0: For storing and retrieving conversation history
- The script uses
dotenv
to load environment variables, including the OpenAI API key.
- A
ConversableAgent
is created with the following configuration:- Name: "chatbot"
- System message: "You are a helpful AI Assistant."
- LLM config: Uses the GPT-4 model
- Code execution is disabled
- Human input is set to "NEVER"
- A
MemoryClient
is instantiated to handle conversation storage and retrieval.
- A sample conversation is added to the Mem0 memory to provide initial context.
The get_context_aware_response
function:
- Searches for relevant memories using Mem0
- Constructs a prompt with the retrieved context and the user's question
- Generates a reply using the Autogen agent
- The script runs an infinite loop, allowing users to input questions
- For each question, it generates a context-aware response using the Autogen agent and Mem0 memory
- When a user asks a question, the script searches for relevant previous interactions in the Mem0 memory.
- It constructs a prompt that includes this context along with the new question.
- The Autogen agent generates a response based on this context-enriched prompt.
- The response is printed, and the loop continues for the next user input.
This approach allows the chatbot to maintain context across multiple interactions, providing more coherent and relevant responses to user queries.
- Ensure you have the required libraries installed:
autogen
,mem0
, andpython-dotenv
. - Set up your OpenAI API key in the
.env
file. - Run the script:
python bestbuy_basic.py
- Interact with the chatbot by typing your questions when prompted.