Skip to content

create_toolbox_for_new_user

fastagency.studio.app.create_toolbox_for_new_user async #

create_toolbox_for_new_user(
    user_uuid: Union[str, UUID]
) -> dict[str, Any]
Source code in fastagency/studio/app.py
async def create_toolbox_for_new_user(user_uuid: Union[str, UUID]) -> dict[str, Any]:
    await DefaultDB.frontend().get_user(user_uuid=user_uuid)  # type: ignore[arg-type]

    domain = environ.get("DOMAIN", "localhost")
    toolbox_openapi_url = (
        "https://weather.tools.staging.fastagency.ai/openapi.json"
        if "staging" in domain or "localhost" in domain
        else "https://weather.tools.fastagency.ai/openapi.json"
    )

    # Check if default weather toolbox already exists
    models = await get_all_models_for_user(user_uuid=user_uuid, type_name="toolbox")
    if models:
        raise HTTPException(status_code=400, detail="Weather toolbox already exists")

    _, validated_model = await create_model(
        cls=Toolbox,
        type_name="toolbox",
        user_uuid=user_uuid,
        name="WeatherToolbox",
        openapi_url=toolbox_openapi_url,
    )
    return validated_model