fastrag.serve.app#

The FastAPI app: create_app(), lifespan, middleware, handlers.

Functions

create_app(*, engine, chat_store[, config])

Build the serving app.

fastrag.serve.app.create_app(*, engine, chat_store, config=None)[source]#

Build the serving app.

A thin adapter over its two collaborators, laid out in the example the SDK ships: a QueryEngine and a ChatStore. The app itself owns no database engine and no ORM session — chatting goes through the store’s methods, generation through engine.stream, and the advisory lock and /healthz connection check borrow the store’s engine via its engine property. Both collaborators are required: there is no half-configured mode.

Parameters:
  • engine (QueryEngine) – The QueryEngine the API exposes — the single place retrieval and generation happen.

  • chat_store (ChatStore) – The ChatStore all session/chat/message persistence goes through. Already entered by the caller (async with ... as chat_store).

  • config (ServeConfig | None) – ServeConfig. Defaults to a config with an empty allowed_origins list.

Returns:

A FastAPI app serving /healthz and the full /v1 chats API.

Return type:

FastAPI