Skip to content

app

Main Entry Point for the EleanorAI Framework Backend FastAPI application.

This module serves as the main entry point for the Eleanor Backend API. It initializes the FastAPI application, sets up exception handlers, adds middleware, and includes routers for different API endpoints.

The API application must be launched via the backend API command in the Eleanor CLI so that configuration and pre-launch checks are performed.

Attributes

APP_PREFIX module-attribute

APP_PREFIX = '/api'

APP_REDOC_URL module-attribute

APP_REDOC_URL = '/redoc'

app module-attribute

app = FastAPI(
    version=__version__,
    lifespan=lifespan,
    redoc_url=APP_REDOC_URL,
    generate_unique_id_function=custom_generate_unique_id,
)

Classes

Functions

custom_generate_unique_id

custom_generate_unique_id(route: APIRoute)

Generates a unique ID for a given API route. This is needed to reduce the insane default method name lengths for generated clients under the default methodology.

Parameters:

  • route (APIRoute) –

    The API route for which to generate the unique ID.

Returns:

  • str

    The generated unique ID.

Raises:

  • ValueError

    If a duplicate route ID is detected.

custom_validation_exception_handler async

custom_validation_exception_handler(
    request: BaseRequest, exc: RequestValidationError
)

general_exception_handler async

general_exception_handler(
    request: BaseRequest, exc: Exception
)

http_error_handler async

http_error_handler(request: Request, exc: HTTPException)

lifespan async

lifespan(app: FastAPI)

redirect_to_api

redirect_to_api()

Redirect to the API documentation

service_exception_handler async

service_exception_handler(
    request: BaseRequest, exc: ServiceError
)