Skip to content

create_model

fastagency.studio.helpers.create_model async #

create_model(
    cls: type[T],
    type_name: str,
    user_uuid: Union[str, UUID],
    background_tasks: Optional[BackgroundTasks] = None,
    **kwargs: Any
) -> tuple[UUID, dict[str, Any]]
Source code in fastagency/studio/helpers.py
async def create_model(
    cls: type[T],
    type_name: str,
    user_uuid: Union[str, UUID],
    background_tasks: Optional[BackgroundTasks] = None,
    **kwargs: Any,
) -> tuple[UUID, dict[str, Any]]:
    model = cls(**kwargs)
    model_uuid = uuid.uuid4()

    validated_model = await add_model_to_user(
        user_uuid=str(user_uuid),
        type_name=type_name,
        model_name=cls.__name__,  # type: ignore [attr-defined]
        model_uuid=str(model_uuid),
        model=model.model_dump(),
        background_tasks=background_tasks,  # type: ignore[arg-type]
    )
    return model_uuid, validated_model