A conversational AI customer support bot built with LangGraph, Ollama, and LangChain. The bot can handle customer inquiries and use tools to provide helpful information.
- Conversational AI: Powered by Llama 3.2 model via Ollama
- Tool Integration: Built-in tools for common support tasks
- Memory: Maintains conversation context across interactions
- Extensible: Easy to add new tools and capabilities
- Current Time: Get the current date and time
- Random Number Generator: Generate random numbers within a specified range
- Calculator: Perform basic mathematical operations (addition)
- Customer Support Info: Provide information about billing, technical support, returns, shipping, and account management
- Python 3.8 or higher
- Windows, macOS, or Linux
git clone <your-repository-url>
cd "customer support bot"# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activatepip install -r requirements.txt- Download Ollama from https://ollama.ai/
- Run the installer and follow the setup instructions
brew install ollamacurl -fsSL https://ollama.ai/install.sh | shOpen a new terminal window and start the Ollama service:
ollama serveKeep this terminal window open while using the bot.
In another terminal window, download the required model:
ollama pull llama3.2This will download the Llama 3.2 model (approximately 2GB). Wait for the download to complete.
Check if the model is available:
ollama listYou should see llama3.2 in the list of available models.
- Make sure Ollama is running (
ollama servein a separate terminal) - Activate your virtual environment
- Run the bot:
python flow.pyGetting Current Time:
🤖 Pass your prompt here: What time is it?
Generating Random Numbers:
🤖 Pass your prompt here: Generate a random number between 1 and 100
Mathematical Calculations:
🤖 Pass your prompt here: What's 25 plus 37?
Customer Support:
🤖 Pass your prompt here: I need help with billing
🤖 Pass your prompt here: How do I return an item?
🤖 Pass your prompt here: What are your shipping options?
General Conversation:
🤖 Pass your prompt here: Hello, how can you help me?
Type quit, exit, or press Ctrl+C to stop the bot.
customer support bot/
├── flow.py # Main application file
├── tool.py # Tool definitions
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore file
└── README.md # This file
-
Connection Error: If you see a connection error, make sure Ollama is running with
ollama serve -
Model Not Found: If you get a model error, ensure you've downloaded the model with
ollama pull llama3.2 -
Import Errors: Make sure you've activated your virtual environment and installed all requirements
-
Tool Binding Error: Ensure you're using the correct Ollama model that supports tool calling
# Check if Ollama is running
curl http://localhost:11434/api/tags
# List available models
ollama list
# Test model directly
ollama run llama3.2 "Hello"To add new tools, edit tool.py:
- Create a new function with the
@tooldecorator - Add proper type hints and docstring
- Add the tool to the
Xlist at the bottom of the file
Example:
@tool
def my_new_tool(param: str) -> str:
"""Description of what this tool does."""
return f"Result: {param}"- Change Model: Edit the model name in
flow.py(line 12) - Modify Personality: Add system prompts or modify the chatbot function
- Add Memory: The bot already has conversation memory enabled
langgraph: For building conversational AI workflowslangchain-ollama: For integrating with Ollama modelslangchain-core: Core LangChain functionalitycolorama: For terminal text coloringtyping-extensions: Enhanced type hintspydantic: Data validation
This project is open source. Feel free to modify and distribute as needed.
For issues or questions:
- Check the troubleshooting section above
- Ensure all installation steps were completed
- Verify Ollama is running and the model is downloaded