25 lines
670 B
Python
25 lines
670 B
Python
"""FastAPI dependencies for the EPUB search app."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Annotated
|
|
|
|
import httpx
|
|
from fastapi import Depends, Request
|
|
|
|
from python.ebook_search.config import EbookSearchConfig
|
|
|
|
|
|
def get_config(request: Request) -> EbookSearchConfig:
|
|
"""Get the loaded search config from app state."""
|
|
return request.app.state.config
|
|
|
|
|
|
def get_http_client(request: Request) -> httpx.AsyncClient:
|
|
"""Get the shared LLM HTTP client from app state."""
|
|
return request.app.state.http_client
|
|
|
|
|
|
AppConfig = Annotated[EbookSearchConfig, Depends(get_config)]
|
|
AppHttpClient = Annotated[httpx.AsyncClient, Depends(get_http_client)]
|