"""
Test Ollama instrumentation against local Latitude instance.

Required env vars:
- LATITUDE_API_KEY

Requires Ollama running locally with a model pulled:
  ollama pull llama3.2

Install: uv add ollama
"""

import os

import ollama

from latitude_telemetry import Latitude, capture

# Initialize telemetry pointing to local instance
latitude = Latitude(
    api_key=os.environ["LATITUDE_API_KEY"],
    project=os.environ["LATITUDE_PROJECT_SLUG"],
    instrumentations={"ollama": ollama},
    disable_batch=True,
)


@capture("test-ollama-completion", {"tags": ["python", "test"], "session_id": "example"})
def test_ollama_completion():
    response = ollama.chat(
        model="llama3.2",
        messages=[{"role": "user", "content": "Say 'Hello from Ollama!' in exactly 5 words."}],
    )

    return response["message"]["content"]


if __name__ == "__main__":
    test_ollama_completion()
    latitude.flush()
