Skip to content

Toolbox

fastagency.studio.models.toolboxes.toolbox.Toolbox #

Bases: Model

name instance-attribute #

name: str

openapi_auth class-attribute instance-attribute #

openapi_auth: Optional[
    Union[OpenAPIAuthTokenRef, OpenAPIAuthRef]
] = None

openapi_url instance-attribute #

openapi_url: URL

create_autogen async classmethod #

create_autogen(
    model_id: UUID, user_id: UUID, **kwargs: Any
) -> OpenAPI
Source code in fastagency/studio/models/toolboxes/toolbox.py
@classmethod
async def create_autogen(
    cls, model_id: UUID, user_id: UUID, **kwargs: Any
) -> OpenAPI:
    my_model = await cls.from_db(model_id)

    # Download OpenAPI spec
    with httpx.Client() as httpx_client:
        response = httpx_client.get(my_model.openapi_url)  # type: ignore[arg-type]
        response.raise_for_status()
        openapi_spec = response.text

    client = OpenAPI.create(openapi_spec)

    return client

from_db async classmethod #

from_db(model_id: UUID) -> T
Source code in fastagency/studio/models/base.py
@classmethod
async def from_db(cls: type[T], model_id: UUID) -> T:
    my_model_dict = await DefaultDB.backend().find_model(model_id)
    my_model = cls(**my_model_dict["json_str"])

    return my_model

get_reference_model classmethod #

get_reference_model() -> Type[ObjectReference]
Source code in fastagency/studio/models/base.py
@classmethod
def get_reference_model(cls) -> "Type[ObjectReference]":
    if cls._reference_model is None:
        raise ValueError("reference model not set")
    return cls._reference_model