https://github.com/davidhintelmann/chatzilla
Query local ollama instance to explore the world of open source large language models
https://github.com/davidhintelmann/chatzilla
Last synced: 8 months ago
JSON representation
Query local ollama instance to explore the world of open source large language models
- Host: GitHub
- URL: https://github.com/davidhintelmann/chatzilla
- Owner: davidhintelmann
- Created: 2025-05-18T19:51:35.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-20T05:42:38.000Z (about 1 year ago)
- Last Synced: 2025-07-05T11:44:09.278Z (12 months ago)
- Language: Python
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# chatzilla
Query local ollama instance to explore the world of open source large language models.
Provides a simple and intuitive way to send prompts, start conversations,
and retrieve chat histories.
## Take a Gander
- Checkout `demo/demo.ipynb` jupyter notebook to get a quick demo on the capabilties of this library.
- Jump into `demo/chat.py` to extend an ongoing conversation.
- chatzilla folder is the package developed as shown below.
## Features
- Send single prompts or start conversations
- Continue conversations while including chat history
- Retrieve chat history and assistant responses
## Installation
clone this repository and install the requirements with:
```pwsh
pip install -r requirements.txt
```
use the following command to point your chat requests to ollama's api endpoint
```python
from dotenv import load_dotenv
load_dotenv()
ollama_url = os.getenv("OLLAMA_CHAT") # http://localhost:11434/api/chat
```
**Recommend:** create a python virtual environment first.
If you haven't done this before, please check the python [docs](https://docs.python.org/3/library/venv.html) for more information.
## Usage
### Single Prompt
Use the `PromptOllama` function to send a single prompt to LLaMA.
```python
from chatzilla import PromptOllama
response = PromptOllama("What do you call a fake noodle?", "llama3.1")
print(response) # prints "An impasta!"
```
#### Conversation
Use the `ChatOllama` class to start and continue conversations.
```python
from chatzilla import ChatOllama
chat = ChatOllama("Hello!", "llama3.1")
response = chat.begin()
print(response) # prints "How are you today?"
next_response = chat.next("I'm good, thanks!")
print(next_response) # prints something like a continuation of the conversation
```
#### Chat History
Use the `history` method to retrieve the current chat history.
```python
print(chat.history()) # prints list of chat history, example below:
# [
# {"role": "user", "content": "Hello!"},
# {"role": "assistant", "content": "How are you today?"}
# ]
```