ollama
Pydantic models for Ollama endpoints.
Classes
OllamaConfigForm
Bases: BaseModel
Configuration for Ollama API settings.
This form is used to update the global Ollama configuration, including enabling/disabling the API, setting base URLs, and configuring specific API settings like keys.
- Code Reference routers ollama Classes OllamaClient Functions update_config
Attributes
ENABLE_OLLAMA_API
Whether to enable the Ollama API integration.
OLLAMA_BASE_URLS
A list of base URLs for Ollama instances (e.g., http://localhost:11434).
OLLAMA_API_CONFIGS
A dictionary mapping URL indices (as strings) or URLs to configuration objects.
Dict Fields
enable(bool, optional): Whether this specific URL is enabled.key(str, optional): API key for authentication (if required).prefix_id(str, optional): A prefix to prepend to model names from this source.tags(List[str], optional): Tags to apply to models from this source.model_ids(List[str], optional): Allowlist of model IDs to show.connection_type(str, optional): Type of connection (e.g., "local").
access_control
Access control configuration for Ollama resources.
Dict Fields
read(dict, optional): Read access control configurationgroup_ids(List[str], optional): List of group IDs that have read accessuser_ids(List[str], optional): List of user IDs that have read access
write(dict, optional): Write access control configurationgroup_ids(List[str], optional): List of group IDs that have write accessuser_ids(List[str], optional): List of user IDs that have write access
When access_control is None, resources are publicly accessible.
When access_control is provided, only specified users and groups have access.
ModelNameForm
Bases: BaseModel
Form for specifying a model name.
Used in various operations like unloading, deleting, or showing model information.
- Code Reference routers ollama Classes OllamaClient Functions
PushModelForm
Bases: BaseModel
Form for pushing a model to a registry.
- Code Reference routers ollama Classes OllamaClient Functions push_model
CreateModelForm
Bases: BaseModel
Form for creating a new model.
- Code Reference routers ollama Classes OllamaClient Functions create_model
CopyModelForm
Bases: BaseModel
Form for copying a model.
- Code Reference routers ollama Classes OllamaClient Functions copy_model
GenerateEmbedForm
Bases: BaseModel
Form for generating embeddings.
- Code Reference routers ollama Classes OllamaClient Functions embed
Attributes
truncate
Whether to truncate the input to the model's context length.
options
Model options (e.g., temperature, context size).
Dict Fields
See Ollama Modelfile documentation for valid parameters.
GenerateEmbeddingsForm
Bases: BaseModel
Form for generating embeddings (legacy endpoint).
- Code Reference routers ollama Classes OllamaClient Functions embeddings
Attributes
options
Model options.
Dict Fields
See Ollama Modelfile documentation for valid parameters.
GenerateCompletionForm
Bases: BaseModel
Form for generating a completion (single prompt).
- Code Reference routers ollama Classes OllamaClient Functions generate
Attributes
format
The format of the response (e.g., "json").
Dict Fields
If provided as a dictionary, it should be a JSON Schema to enforce a specific output structure.
options
Model parameters like temperature, top_k, etc.
Dict Fields
See Ollama Modelfile documentation for valid parameters.
context
Context parameter returned from a previous request (legacy).
ChatMessage
Bases: BaseModel
A message in a chat conversation.
- Code Reference models ollama Classes GenerateChatCompletionForm Attributes messages
Attributes
tool_calls
List of tool calls generated by the model.
Dict Fields
index(int, optional): The index of the tool call in the sequenceid(str, optional): Unique identifier for the tool callfunction(dict, required): Function call detailsname(str, required): Name of the function/tool to callarguments(dict, required): JSON-serializable arguments for the function
GenerateChatCompletionForm
Bases: BaseModel
Form for generating a chat completion.
- Code Reference routers ollama Classes OllamaClient Functions chat
Attributes
format
Response format (e.g., "json").
Dict Fields
If provided as a dictionary, it should be a JSON Schema to enforce a specific output structure.
options
Model parameters.
Dict Fields
See Ollama Modelfile documentation for valid parameters.
tools
List of tools available to the model.
Dict Fields
type(str, required): The type of tool, e.g. "function".function(dict, required): The function definition.name(str, required): The name of the function.description(str, optional): A description of the function.parameters(dict, required): A JSON schema defining the function parameters.
ConnectionVerificationForm
Bases: BaseModel
Form for verifying an Ollama connection.
- Code Reference routers ollama Classes OllamaClient Functions verify_connection
UrlForm
Bases: BaseModel
Form containing a URL, used for downloading models.
- Code Reference routers ollama Classes OllamaClient Functions download_model