airflow.providers.common.ai.hooks.ollama¶
Classes¶
Load control for a model served by Ollama, through its native |
Functions¶
|
Return the server root of an Ollama URL, dropping a trailing |
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/generateendpoint.- Parameters:
base_url (str | None) – Ollama URL; a trailing
/v1is dropped to reach the native API. WhenNoneor empty, theOLLAMA_BASE_URLenvironment 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_URLis not set.
Known limitation: the connection password is not sent, so no
Authorizationheader is added and servers behind authentication are not supported.- 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
errortext (the response body when it has none).