A local AI-powered CLI chatbot built using Python and Ollama with persistent memory support.
This chatbot:
- runs completely offline
- stores conversation history
- supports multi-turn conversations
- uses local LLMs through Ollama
- requires no API key
Runs AI models locally using Ollama.
Conversation history is stored in memory.json so the chatbot remembers previous chats.
The chatbot maintains context across messages.
No internet or API key required after model download.
Simple terminal-based chatbot.
| Technology | Purpose |
|---|---|
| Python | Programming language |
| Ollama | Local LLM runtime |
| JSON | Persistent memory storage |
CLI_Chatbot/
│
├── main.py
├── memory.json
├── requirements.txt
├── README.md
└── .gitignore
Download Python: https://www.python.org/downloads/
Download Ollama: https://ollama.com/download
pip install -r requirements.txtExample:
ollama run llama3.2:3bThis downloads the model locally.
You can also use:
llama3mistralgemma:2b
python main.pyChat Started...
Type 'exit' to end the conversation.
You: Hello
Assistant: Hi! How can I help you today?
You: My name is Aditya
Assistant: Nice to meet you, Aditya!
You: What is my name?
Assistant: Your name is Aditya.
Conversation history is stored inside:
memory.json
Every message:
- gets added to conversation history
- is sent to the AI model
- gets saved permanently
This allows the chatbot to remember previous conversations even after restarting.
Defines chatbot behavior.
Example:
{
"role": "system",
"content": "You are a helpful assistant."
}Stores user messages.
Example:
{
"role": "user",
"content": "Hello"
}Stores chatbot replies.
Example:
{
"role": "assistant",
"content": "Hi!"
}Possible upgrades:
- Streaming responses
- Semantic memory
- SQLite database
- Voice assistant
- Rich terminal UI
- Tool usage
- GUI interface
- Vector databases
This project demonstrates:
- Python development
- Conversational AI systems
- Local LLM integration
- Persistent memory handling
- CLI application development
- Context management
Recommended .gitignore:
venv/
__pycache__/
*.pyc
memory.jsonThis project is open-source and intended for educational purposes.
Built by Aditya Jhinjha