models
Models module.
models module
Models module.
class ModelWithDetails
Bases: Model
Represents a model with details.
overview : str | None
The overview of the model.
latest_version : ModelVersionWithDetails | None
The details of the latest version of the model.
id : str
name : str
created_at : str
visibility : ModelVisibility
description : str | None
updated_at : str | None
source_url : str | None
license_url : str | None
paper_url : str | None
owner : User
hardware : Hardware
predictions_count : int
categories : list[ModelCategory]
class ModelsSortBy(StrEnum)
Bases: StrEnum
Enumeration of possible sorting options for querying models.
CREATED_AT = 'created_at'
PREDICTION_COUNT = 'prediction_count'
class ModelPaginationOptions
Bases: PaginationOptions
Pagination options for querying models.
sort_by : NotRequired[ModelsSortBy]
The sorting criteria.
sort_direction : NotRequired[SortDirection]
The sorting direction.
category_slugs : NotRequired[list[str]]
The list of category slugs to filter models.
cursor : NotRequired[str]
page_size : NotRequired[int]
class UpdateModelParams
Bases: TypedDict
Parameters for updating a model.
name : NotRequired[str]
The name of the model.
description : NotRequired[str | None]
Description of the model.
visibility : NotRequired[ModelVisibility]
The visibility of the model.
hardware_identifier : NotRequired[str]
The identifier of the hardware used by the model.
source_url : NotRequired[str | None]
Source url from where the model’s code can be referenced.
license_url : NotRequired[str | None]
License url where the model’s usage is specified.
paper_url : NotRequired[str | None]
Paper url from where research info on the model can be found.
overview : NotRequired[str | None]
The overview of the model.
category_slugs : NotRequired[list[str]]
List of model category slugs.
class CreateModelParams
Bases: TypedDict
Parameters for creating a model.
name : str
The name of the model.
hardware_identifier : str
The identifier of the hardware used by the model.
visibility : NotRequired[ModelVisibility]
The visibility of the model.
description : NotRequired[str | None]
Description of the model.
source_url : NotRequired[str | None]
Source url from where the model’s code can be referenced.
license_url : NotRequired[str | None]
License url where the model’s usage is specified.
paper_url : NotRequired[str | None]
Paper url from where research info on the model can be found.
overview : NotRequired[str | None]
The overview of the model.
category_slugs : NotRequired[list[str]]
List of model category slugs.
class ModelsResource(api)
Bases: Resource
Initializes the Resource with an API instance.
- Parameters: api (API) – An instance of the API class.
delete(owner, name)
Delete a model.
- Parameters:
- owner (str) – Username of the model’s owner.
- name (str) – Name of the model.
- Return type: None
async async_delete(owner, name)
Delete a model.
- Parameters:
- owner (str) – Username of the model’s owner.
- name (str) – Name of the model.
- Return type: None
list(pagination_options=None, owner=None)
List models.
- Parameters:
- pagination_options (Optional [ModelPaginationOptions ]) – Optional settings to control pagination behavior.
- owner (Optional[str]) – Username of the model’s owner to fetch models for. If None, all models are fetched.
- Returns: Paginated response containing models and : navigation metadata.
- Return type: PaginatedResponse[Model]
async async_list(pagination_options=None, owner=None)
List models.
- Parameters:
- pagination_options (Optional[ModelPaginationOptions]) – Optional settings to control pagination behavior.
- owner (Optional[str]) – Username of the model’s owner to fetch models for. If None, all models are fetched.
- Returns: Paginated response containing models and : navigation metadata.
- Return type: PaginatedResponse[Model]
get(owner, name)
Get a model.
- Parameters:
- owner (str) – Username of the model’s owner.
- name (str) – Name of the model.
- Returns: A model object.
- Return type: ModelWithDetails
async async_get(owner, name)
Get a model.
- Parameters:
- owner (str) – Username of the model’s owner.
- name (str) – Name of the model.
- Returns: A model object.
- Return type: ModelWithDetails
create(params)
Create a model.
- Parameters: params (CreateModelParams) – Model creation parameters.
- Returns: The new model.
- Return type: ModelWithDetails
async async_create(params)
Create a model.
- Parameters: params (CreateModelParams) – Model creation parameters.
- Returns: The new model.
- Return type: ModelWithDetails
update(owner, name, params)
Update a model.
- Parameters:
- owner (str) – Username of the model’s owner.
- name (str) – Name of the model.
- params (UpdateModelParams) – The fields to update.
- Returns: The updated model.
- Return type: ModelWithDetails
async async_update(owner, name, params)
Update a model.
- Parameters:
- owner (str) – Username of the model’s owner.
- name (str) – Name of the model.
- params (UpdateModelParams) – The fields to update.
- Returns: The updated model.
- Return type: ModelWithDetails
search(q, pagination_options=None)
Search models.
- Parameters:
- q (str) – The search query.
- pagination_options (Optional [PaginationOptions ]) – Optional settings to control pagination behavior.
- Returns: Paginated response containing models : and navigation metadata.
- Return type: PaginatedResponse[Model]
async async_search(q, pagination_options=None)
Search models.
- Parameters:
- q (str) – The search query.
- pagination_options (Optional [PaginationOptions ]) – Optional settings to control pagintation behavior.
- Returns: Paginated response containing models : and navigation metadata.
- Return type: PaginatedResponse[Model]