feat(backend): add dependency injection and update main entry point
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
44028ebd6e
commit
4cf930dc59
|
|
@ -0,0 +1,24 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from functools import lru_cache
|
||||
|
||||
from app.core.config import Settings, get_settings
|
||||
|
||||
@lru_cache()
|
||||
def get_settings_cached() -> Settings:
|
||||
return get_settings()
|
||||
|
||||
|
||||
# Placeholder for future DI wiring. Tests patch classes directly, so we keep
|
||||
# a minimal API here to avoid import-time side effects.
|
||||
def get_llm_client():
|
||||
settings = get_settings_cached()
|
||||
from app.services.llm_client import LLMClient
|
||||
return LLMClient(settings)
|
||||
|
||||
|
||||
def get_rag_service():
|
||||
# Import lazily to avoid circular imports in tests
|
||||
from app.services.rag import RAGService
|
||||
llm = get_llm_client()
|
||||
return RAGService(llm_client=llm)
|
||||
|
|
@ -2,12 +2,14 @@ from fastapi import FastAPI
|
|||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.routers import ingest, query
|
||||
from app.core.config import get_settings
|
||||
|
||||
settings = get_settings()
|
||||
app = FastAPI(title="RAG Video Q&A", version="1.0.0")
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:5173", "http://localhost:3000"],
|
||||
allow_origins=settings.cors_origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
|
|
|||
Loading…
Reference in New Issue