This is a simple AI chatbot application that integrates Ollama — a local LLM runner — with Gradio — a web interface framework for building ML apps.
- Uses a local large language model (e.g., LLaMA 3) served via Ollama.
- Interactive, clean, and easy-to-use web chat interface using Gradio.
- Keeps a running conversation history.
- Fully offline and runs locally on your machine.
- Ubuntu Linux (tested on Ubuntu 22.04)
- Python 3.8 or higher
pip
- At least 8 GB of RAM (16 GB recommended for LLaMA 3)
- Ollama installed and a model available (e.g.,
llama3
)
Download and install Ollama from the official site:
👉 https://ollama.com/download
Open a terminal and pull the model:
ollama run llama3
Leave this running or ensure Ollama is running in the background.
In the same folder as your Python script, run:
pip install gradio requests
Save the script as chatbot_ollama_gradio.py
, then execute:
python3 chatbot_ollama_gradio.py
This will launch the Gradio web interface in your default browser.
chatbot_ollama_gradio.py # Main chatbot script
README.md # This documentation file
- Sends user messages to the local Ollama server at
http://localhost:11434/api/chat
- Constructs a chat history using the format expected by the OpenAI-style API.
- Displays messages in a chat UI powered by Gradio.
User: Hello!
Assistant: Hello! How can I help you today?
User: What's the capital of France?
Assistant: The capital of France is Paris.
This project is provided for educational purposes only. Please consult each model's license on the Ollama website before using in production.