airflow.providers.common.ai.hooks.lmstudio¶
Classes¶
Load control for a model served by LM Studio, through its native |
Functions¶
|
Return the server root of an LM Studio URL, dropping a trailing |
Module Contents¶
- airflow.providers.common.ai.hooks.lmstudio.build_lmstudio_native_root(base_url)[source]¶
Return the server root of an LM Studio URL, dropping a trailing
/api/v1or/v1.
- class airflow.providers.common.ai.hooks.lmstudio.LMStudioBackend(base_url, model_name, *, transport=None)[source]¶
Load control for a model served by LM Studio, through its native
/api/v1/modelsendpoints.Pass the class to
ensure_model_readyasbackend_factory=LMStudioBackend.The model list request gets timeout seconds and the load request gets what the list request left of them. Each is an httpx2 timeout, which applies to the connect, write and read phases separately, so the two requests together can still take longer than timeout.
- Parameters:
base_url (str | None) – LM Studio URL; a trailing
/v1(OpenAI-compatible) or/api/v1(native) is dropped to reach the server root.model_name (str) – Model key as listed by
GET /api/v1/models; any other name raisesValueErrorinstead of loading a model.transport (httpx2.BaseTransport | None) – Optional httpx2 transport, mainly to stub the server in tests.
- Raises:
ValueError – If base_url is
Noneor empty.
Known limitation: no
Authorizationheader is sent, so LM Studio with API token authentication turned on is not supported.- load(*, timeout)[source]¶
Load the model unless LM Studio already lists it with a loaded instance, within timeout seconds.
- Raises:
TimeoutError – If a request exceeds the time it was given (see the class docstring).
httpx2.ConnectError – If the server cannot be reached.
httpx2.HTTPStatusError – If the server answers with an error status; the message says whether listing or loading failed and carries the
errortext when the body has one, otherwise the start of the response body.ValueError – If the model list is not a JSON object whose
modelsis a list of objects (the message carries the body’serrortext when there is one), or if none of its entries has akeyequal to the model name; nothing is loaded then.