Skip to content

kawtareg/chatbot-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

local-chatbot: French Chef Chatbot

A CLI conversational chatbot playing the role of a Michelin-starred French chef. Runs entirely locally via Ollama.

Built as part of an LLM & agentic AI learning journey - 4th year Computer Science Engineering, INSA Rouen.

Python Ollama Mistral License Local


Demo

Chatbot demo


Features

  • Multi-turn conversation with full history memory
  • Token-by-token streaming responses
  • reset command to clear conversation memory
  • save command to export conversation history as JSON
  • quit command to exit
  • Configurable personality via config.py
  • Robust API error handling

Stack

Tool Role
Python 3.12 Language
Ollama Local LLM inference
Mistral 7B Language model
openai SDK API client (Ollama-compatible)
python-dotenv Environment variable management

Installation

Prerequisites

  • Mac with Homebrew or equivalent
  • Python 3.12+

1. Clone the project

git clone https://github.com/kawtareg/chatbot-cli
cd chatbot-cli

2. Install Ollama and the model

brew install ollama
brew services start ollama
ollama pull mistral

3. Set up Python environment

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

4. Run the chatbot

python3 main.py

Usage

Enter a query after >>>, quit to exit,
reset to clear memory, save to export the conversation.
 
>>> Bonjour, qui es-tu ?
>>> Donnes moi la recette de la blanquette de veau
>>> save
>>> reset
>>> quit

Saved conversations are stored in history/ as JSON files.


Project structure

local-chatbot/
├── main.py          # entry point
├── chatbot.py       # chatbot logic (streaming, history, commands)
├── config.py        # system prompt and model parameters
├── requirements.txt
├── history/         # saved conversations (git-ignored)
│   └── .gitkeep
└── .gitignore

Customization

Edit config.py to change the chatbot personality:

MODEL = "mistral"       # or llama3, phi3, gemma...
TEMPERATURE = 0.3       # 0 = deterministic, 1 = creative
 
SYSTEM_PROMPT = """You are a Michelin-starred French chef..."""

You can also swap mistral for any model available on Ollama:

ollama pull llama3
ollama pull phi3
ollama pull gemma

What I learned

  • LLM API calls with the openai SDK
  • Conversation history management (messages format)
  • Token-by-token streaming
  • Modular Python project structure
  • JSON data persistence
  • Robust error handling with try/except

Roadmap

  • RAG system to give the chef access to external recipes
  • Agentic version capable of searching recipes online

Author

Kawtar El GueddariGitHub · INSA Rouen Normandie

About

CLI chatbot powered by Mistral 7B running locally via Ollama — multi-turn conversation, streaming, JSON history

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages