agents.clients.ollama#

Module Contents#

Classes#

OllamaClient

An HTTP client for interaction with ML models served on ollama.

API#

class agents.clients.ollama.OllamaClient(model: Union[agents.models.OllamaModel, Dict], host: str = '127.0.0.1', port: int = 11434, inference_timeout: int = 30, init_on_activation: bool = True, logging_level: str = 'info', ca_cert: Optional[str] = None, **kwargs)#

Bases: agents.clients.model_base.ModelClient

An HTTP client for interaction with ML models served on ollama.

property supports_tool_calls: bool#

Ollama chat models support tool calling, decision models do not. Does not wait for a pull: a model still being pulled is taken for a chat model.

Return type:

bool

property supports_decisions: bool#

Whether the model is a decision model, by its Ollama capabilities. Waits for a pull in progress.

Return type:

bool

property context_length: Optional[int]#

The context length the model is served with: num_ctx from the model options when set, since requests carry it, else what Ollama reports for the loaded model, else the length the model was trained with. None when nothing can be read

serialize() → Dict#

Get client json

Return type:

Dict

check_connection() → None#

initialize.

Return type:

None

initialize() → None#

initialize.

Return type:

None

inference(inference_input: Dict[str, Any]) → Optional[MutableMapping]#

inference.

Parameters:

inference_input (dict[str, Any])

Return type:

dict | None

deinitialize()#

deinitialize.