Skip to main content

Respan instrumentation plugin for Ollama

Project description

respan-instrumentation-ollama

Respan instrumentation plugin for Ollama. It instruments the official Ollama Python client and emits chat, completion, and embedding spans into the Respan tracing pipeline.

Configuration

1. Install

pip install respan-ai respan-instrumentation-ollama ollama

ollama is the official Ollama Python client. A running Ollama server is required for real model calls.

2. Set Environment Variables

Variable Required Description
RESPAN_API_KEY Yes Your Respan API key.
RESPAN_BASE_URL No Defaults to https://api.respan.ai/api.
OLLAMA_HOST No Ollama server URL. Defaults to the Ollama client default.
OLLAMA_MODEL No Model used by your application.

Quickstart

import os

from dotenv import load_dotenv
from ollama import Client
from respan import Respan, workflow
from respan_instrumentation_ollama import OllamaInstrumentor

load_dotenv()

respan = Respan(
    api_key=os.environ["RESPAN_API_KEY"],
    base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"),
    instrumentations=[OllamaInstrumentor()],
)
client = Client(host=os.getenv("OLLAMA_HOST"))


@workflow(name="ollama_quickstart")
def run() -> str:
    response = client.chat(
        model=os.getenv("OLLAMA_MODEL", "llama3.2"),
        messages=[{"role": "user", "content": "Reply with one concise sentence."}],
    )
    return response["message"]["content"]


print(run())
respan.flush()
respan.shutdown()

Further Reading

See the Respan example projects for runnable scripts.

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

respan_instrumentation_ollama-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

respan_instrumentation_ollama-0.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file respan_instrumentation_ollama-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_ollama-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d0e385031f9fdf2d3746038c0f0231c50dc18c2349c5374fedcf850c6d722ce
MD5 245a266340c559290c22dfec752c728e
BLAKE2b-256 5fb44a3d3e48a3886c864defc03db48e207ed9f312820caabcb74d55225487a9

See more details on using hashes here.

File details

Details for the file respan_instrumentation_ollama-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_ollama-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbe25e8cb94eb22511a7cb8d9d87d65963bf3a44c62d9c6154de1d0fd637536c
MD5 8dbb32d390f4a6b03cdf00713ae53e05
BLAKE2b-256 8ce081184da220a66b9d944c37c50428b1791aa9f2fa6f2f1c9a60dcf0f798a6

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