A simple SDK for interacting with the Ollama API by automatically creating a conversation (chat history)
Project description
QV Ollama SDK
A simple SDK for interacting with the Ollama API.
Features
- Simple conversation management
- Support for synchronous API calls
- Streaming response support
- Explicit parameter handling (no unnecessary defaults)
- User-friendly client interface
Installation
pip install qv-ollama-sdk
Quick Start
from qv_ollama_sdk import OllamaChatClient
# Create a client with a system message
client = OllamaChatClient(
model_name="gemma2:2b",
system_message="You are a helpful assistant."
)
# Simple chat - uses Ollama's default parameters
response = client.chat("What is the capital of France?")
print(response)
# Continue the conversation
response = client.chat("And what is its population?")
print(response)
# Set specific parameters only when you need them
client.temperature = 1.0 # Using property setter
client.max_tokens = 500 # Using property setter
client.set_parameters(num_ctx=2048) # For multiple parameters
# Get conversation history
history = client.get_history()
Streaming Responses
from qv_ollama_sdk import OllamaChatClient
client = OllamaChatClient(model_name="gemma2:2b")
# Stream the response
for chunk in client.stream_chat("Explain quantum computing."):
print(chunk, end="", flush=True)
Advanced Usage
For more control, you can use the lower-level API:
from qv_ollama_sdk import Conversation, OllamaConversationService, ModelParameters
# Create a conversation
conversation = Conversation(model_name="gemma2:2b")
conversation.add_system_message("You are a helpful assistant.")
conversation.add_user_message("What is the capital of France?")
# Generate a response with specific parameters
service = OllamaConversationService()
parameters = ModelParameters(temperature=0.7, num_ctx=2048)
response = service.generate_response(conversation, parameters)
print(response.content)
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
qv_ollama_sdk-0.3.0.tar.gz
(9.9 kB
view details)
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 qv_ollama_sdk-0.3.0.tar.gz.
File metadata
- Download URL: qv_ollama_sdk-0.3.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25479b32b835ebb0d288a26ea358feae82d454429aaea4ac8e042e60e4016287
|
|
| MD5 |
69c847b266cd68d7856473fd5f46520c
|
|
| BLAKE2b-256 |
671fad0a3a18fe6a1975dd79ae3fc744b415d7daed09bf9512aa5a583cc72f14
|
File details
Details for the file qv_ollama_sdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: qv_ollama_sdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d150269f989e4d7e6b2f57bb08fdaf018eaadcd019af2c268fc99f4a00185b9
|
|
| MD5 |
ab6eefb46ff6cfc2b1c7989e43222a56
|
|
| BLAKE2b-256 |
abb3998fa5f862bf5602e6c6bcea68d0d7da398b20aa8d9d793ae045429b3a73
|