airflow.providers.common.ai.hooks.ollama

Classes

OllamaBackend

Load control for a model served by Ollama, through its native /api/generate endpoint.

Functions

build_ollama_native_root(base_url)

Return the server root of an Ollama URL, dropping a trailing /v1 (the OpenAI-compatible path).

Module Contents

airflow.providers.common.ai.hooks.ollama.build_ollama_native_root(base_url)[source]

Return the server root of an Ollama URL, dropping a trailing /v1 (the OpenAI-compatible path).

class airflow.providers.common.ai.hooks.ollama.OllamaBackend(base_url, model_name, *, transport=None)[source]

Load control for a model served by Ollama, through its native /api/generate endpoint.

Parameters:
  • base_url (str | None) – Ollama URL; a trailing /v1 is dropped to reach the native API. When None or empty, the OLLAMA_BASE_URL environment variable is used.

  • model_name (str) – Model name without the ollama: prefix.

  • transport (httpx2.BaseTransport | None) – Optional httpx2 transport, mainly to stub the server in tests.

Raises:

ValueError – If base_url is not given and OLLAMA_BASE_URL is not set.

Known limitation: the connection password is not sent, so no Authorization header is added and servers behind authentication are not supported.

root[source]
model_name[source]
load(*, timeout)[source]

Load the model, waiting at most timeout seconds.

Raises:
  • TimeoutError – If the server cannot be reached or does not finish loading within timeout.

  • httpx2.HTTPStatusError – If the server answers with an error status; the message names the model and carries the server’s error text (the response body when it has none).

Was this entry helpful?