- Step 14: Brand enforcement service (font/color/logo replacement, WCAG contrast check, LLM prompt context) - Step 15: Enhanced outline & slide content generation with brand context, content summary, "no hallucination" instructions - Step 15b: LLM auto-fallback retry logic across providers (FALLBACK_LLM_PROVIDERS env) - Step 16: Redis/ARQ job queue — worker entry point, presentation & master deck workers, job status/SSE endpoints, graceful fallback to BackgroundTasks when Redis unavailable Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
748 B
Python
25 lines
748 B
Python
from contextlib import asynccontextmanager
|
|
import os
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from services.database import create_db_and_tables
|
|
from services.redis_service import close_arq_pool
|
|
from utils.get_env import get_app_data_directory_env
|
|
from utils.model_availability import (
|
|
check_llm_and_image_provider_api_or_model_availability,
|
|
)
|
|
|
|
|
|
@asynccontextmanager
|
|
async def app_lifespan(_: FastAPI):
|
|
"""
|
|
Lifespan context manager for FastAPI application.
|
|
Initializes the application data directory and checks LLM model availability.
|
|
|
|
"""
|
|
os.makedirs(get_app_data_directory_env(), exist_ok=True)
|
|
await create_db_and_tables()
|
|
await check_llm_and_image_provider_api_or_model_availability()
|
|
yield
|
|
await close_arq_pool()
|