Skip to content

pixano_inference.pydantic.base

Pydantic base models for request and response.

APIRequest

Bases: BaseRequest, ABC

API request model.

Attributes:

Name Type Description
api_key str

API key.

secret_key str

Secret key.

BaseRequest

Bases: BaseModel, ABC

Base request model.

Attributes:

Name Type Description
model str

Name of the model.

to_base_model(base_model)

Convert request to input type.

Source code in pixano_inference/pydantic/base.py
def to_base_model(self, base_model: type[T]) -> T:
    """Convert request to input type."""
    if not issubclass(base_model, BaseModel):
        raise ValueError(f"base_model must be a subclass of pydantic's BaseModel, got {base_model.__name__}.")
    return base_model.model_validate(self.model_dump(include=list(base_model.model_fields.keys())))

BaseResponse

Bases: BaseModel, ABC

Base response model.

Attributes:

Name Type Description
task_id

ID of the celery task.

status str

Status of the celery task.

timestamp datetime

Timestamp of the response.

processing_time float

Processing time of the response.

metadata dict[str, Any]

Metadata of the response.

data Any

Data of the response.

CeleryTask

Bases: BaseModel

Celery task model.

Attributes:

Name Type Description
task_id

ID of the celery task.

status str

Status of the celery task.