Run Ollama models easily, anywhere – including online platforms like Google Colab
Project description
Quick Llama
A Python wrapper for Ollama that simplifies managing and interacting with LLMs on colab with multi model and reasoning model support.
QuickLlama automates server setup, model management, and seamless interaction with LLMs, providing an effortless developer experience.
🚀 Colab-Ready: Easily run and experiment with QuickLlama on Google Colab for hassle-free, cloud-based development!
Note: Don’t forget to use a GPU if you actually want it to perform well!
Installtion
pip install quick-llama
!pip install quick-llama
Serve a model
from quick_llama import QuickLlama
model = 'gemma3'
quick_llama = QuickLlama(model_name=model,verbose=True)
quick_llama.init() # -> starts the server in background
Serve QuickLlama
from quick_llama import QuickLlama
from ollama import chat
from ollama import ChatResponse
# Defaults to gemma3
model = 'gemma3'
quick_llama = QuickLlama(model_name=model,verbose=True)
quick_llama.init()
response: ChatResponse = chat(model=model, messages=[
{
'role': 'user',
'content': 'Why is the sky blue?',
},
])
print(response['message']['content'])
# or access fields directly from the response object
print(response.message.content)
quick_llama.stop()
MultiModels
import requests
import os
from ollama import chat
from quick_llama import QuickLlama
model = 'gemma3'
quick_llama = QuickLlama(model_name=model,verbose=True)
quick_llama.init()
# Step 1: Download the image
img_url = "https://raw.githubusercontent.com/nuhmanpk/quick-llama/main/images/llama-image.webp" # quick llama cover photo
img_path = "temp_llama_image.webp"
with open(img_path, "wb") as f:
f.write(requests.get(img_url).content)
# Step 2: Send the image to the model
response = chat(
model=model,
messages=[
{
"role": "user",
"content": "Describe what you see in this photo.",
"images": [img_path],
}
]
)
# Step 3: Print the result
print(response['message']['content'])
# Step 4: Clean up the image file
os.remove(img_path)
from quick_llama import QuickLlama
from ollama import chat
from ollama import ChatResponse
# Defaults to gemma3
quick_llama = QuickLlama(model_name="gemma3")
quick_llama.init()
response: ChatResponse = chat(model='gemma3', messages=[
{
'role': 'user',
'content': 'what is 6 times 5?',
},
])
print(response['message']['content'])
print(response.message.content)
Use with Langchain
from quick_llama import QuickLlama
from langchain_ollama import OllamaLLM
model_name = "gemma3"
quick_llama = QuickLlama(model_name=model_name,verbose=True)
quick_llama.init()
model = OllamaLLM(model=model_name)
model.invoke("Come up with 10 names for a song about parrots")
Use custom Models
quick_llama = QuickLlama() # Defaults to mistral
quick_llama.init()
# Custom Model
# Supports all models from https://ollama.com/search
quick_llama = QuickLlama(model_name="custom-model-name")
quick_llama.init()
List Models
quick_llama.list_models()
Stop Model
quick_llama.stop_model("gemma3")
Stop Server
quick_llama.stop()
Made with ❤️ by Nuhman. Happy Coding 🚀
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quick_llama-0.1.0.tar.gz.
File metadata
- Download URL: quick_llama-0.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af7a95d730e43a520b6dae0a4e592bad917f23e354a634012f14bb4c0f8c15b5
|
|
| MD5 |
338aaa97bbbc8e28f9a9a94f95abe684
|
|
| BLAKE2b-256 |
c9bfbdfe5532a0ad7bc1a7b5cc113643a358b0e9a722041cc11e4ef19221ae05
|
File details
Details for the file quick_llama-0.1.0-py3-none-any.whl.
File metadata
- Download URL: quick_llama-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c27ca5d7fcca85dc86cd76d4179ea9bb532b6b4c4f83f8772a920f44b08ed610
|
|
| MD5 |
4f08c12f3023b50526acda5d5e464c23
|
|
| BLAKE2b-256 |
1b550d948c4185071a9e56ede698e22568f502fa0e57664eb37e94801c0b6228
|