Built using the Langchain framework and Ollama, this chatbot helps me explore the topic of AI and large language models (LLMs).
- Context memory: The chatbot remembers past conversations, so it gives more relevant responses.
- Customization: If you use DeepSeek R1, you can choose to show or hide its thinking using the
/toggle_thoughts
command.
- Docker Desktop for Windows
- Windows Subsystem for Linux (WSL)
- Internet connection
- At least 15GB of storage
Follow this procedure to install.
-
Clone the repository.
git clone https://github.com/boysbytes/langchain-chatbot.git cd langchain-chatbot
-
Create the Ollama data directory.
mkdir data mkdir ./data/ollama
-
Build the Docker image.
docker-compose build
-
Start the services.
docker-compose up -d
-
Pull a model.
docker exec -it ollama ollama run deepseek-r1:1.5b
-
Access the chatbot:
http://localhost:3000
-
By default, its thinking process is hidden. You can see its thinking process by sending this command:
/toggle_thoughts
-
When you're done, stop and clean-up.
docker-compose down
-
Start the Docker services.
-
Replace the model.
# List the models docker exec -it ollama ollama list # Delete a model docker exec -it ollama ollama rm <model_name> # Pull another model docker exec -it ollama ollama run <model_name>
-
Update the model name in
chatbot.py
class Chatbot: def __init__(self, model_name="<model_name>", temperature=0.6): # Initialize memory to store conversation history self.memory = ConversationBufferMemory(return_messages=True)
For example, if you use
deepseek-r1:1.5b
, then update as follows:class Chatbot: def __init__(self, model_name="deepseek-r1:1.5b", temperature=0.6): # Initialize memory to store conversation history self.memory = ConversationBufferMemory(return_messages=True)
-
Rebuild and run the containers.
docker-compose up --build
-
Ensure Docker Desktop is running.
-
Check container logs: If something doesn't work, monitor the logs for errors:
docker-compose logs -f
-
Verify the model was pulled successfully.
docker exec ollama-chatbot ollama list
-
Restart services: If issues persist, restart the containers:
docker-compose down docker-compose up -d