974bab7cd8
- config.py: dataclasses → pydantic-settings BaseSettings (flat AppConfig, env vars auto-loaded from .env, type-safe validation) - api_client.py: HTTPAPIClient takes AppConfig directly (APIConfig removed); tenacity retry on 5 methods (reset/ingest/list/delete/feedback) — retries on 5xx + TransportError, 3 attempts, exponential backoff 1-8s - container.py: manual DI → dependency_injector DeclarativeContainer with providers.Singleton; Container() needs no args - app.py: container.X → container.X() calls, remove AppConfig import - requirements.txt: add pydantic-settings, tenacity, dependency-injector Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
16 lines
571 B
Python
16 lines
571 B
Python
from dependency_injector import containers, providers
|
|
|
|
from api_client import HTTPAPIClient
|
|
from config import AppConfig
|
|
from services import ChatService, DocumentService, TTSService
|
|
|
|
|
|
class Container(containers.DeclarativeContainer):
|
|
config = providers.Singleton(AppConfig)
|
|
|
|
api_client = providers.Singleton(HTTPAPIClient, config=config)
|
|
|
|
chat_service = providers.Singleton(ChatService, api_client=api_client)
|
|
document_service = providers.Singleton(DocumentService, api_client=api_client)
|
|
tts_service = providers.Singleton(TTSService, config=config)
|