Skip to main content

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


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.2.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qv_ollama_sdk-0.2.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file qv_ollama_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: qv_ollama_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.5

File hashes

Hashes for qv_ollama_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1a1c785262defc74b4b83c7755c3f899efad993ca328941ea5db00096cc02dd0
MD5 930c2a09f3200c973e90120869e10b9b
BLAKE2b-256 1cd721e1bcf9d99eb310f8f8bdf42b8ec8e7f5cd843f02560b20ce05bb6d8b06

See more details on using hashes here.

File details

Details for the file qv_ollama_sdk-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for qv_ollama_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fd743a0181f3ae2a94b15637d5a2ac64f0e071f822c3c847e49bef2ceb174c6
MD5 4101ffb336401865afb2f657eddfa69b
BLAKE2b-256 26ee130c92a9cfcdc7f5ae309ae4173d0cdb6f4db061e273d7e1ee5d6b8bfb07

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page