- Crea UnsplashService con search, cache disco, traduzione IT->EN - ~30 keyword B2B italiane tradotte in dizionario statico - Cache in-memory + persistenza su disco (unsplash_cache.json) - Retry automatico su errori di rete, no-retry su 401/403 - Rate limiting awareness via X-Ratelimit-Remaining header - Aggiunge campo unsplash_api_key a Settings schema - Router settings espone unsplash_api_key_masked + configured - Merge None-preserving per unsplash_api_key nel PUT
55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
"""Pydantic schemas per la configurazione applicativa.
|
|
|
|
Settings contiene la configurazione persistita in CONFIG_PATH/settings.json.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from backend.constants import NICCHIE_DEFAULT
|
|
|
|
|
|
class Settings(BaseModel):
|
|
"""Configurazione applicativa persistita su disco.
|
|
|
|
Salvata in CONFIG_PATH/settings.json.
|
|
"""
|
|
|
|
api_key: Optional[str] = Field(
|
|
default=None,
|
|
description="Chiave API Anthropic. Se None, la generazione è disabilitata.",
|
|
)
|
|
llm_model: str = Field(
|
|
default="claude-sonnet-4-5",
|
|
description="Modello Claude da usare per la generazione.",
|
|
)
|
|
nicchie_attive: list[str] = Field(
|
|
default_factory=lambda: list(NICCHIE_DEFAULT),
|
|
description="Lista delle nicchie target attive per il calendario.",
|
|
)
|
|
lingua: str = Field(
|
|
default="italiano",
|
|
description="Lingua dei contenuti generati.",
|
|
)
|
|
frequenza_post: int = Field(
|
|
default=3,
|
|
ge=1,
|
|
le=7,
|
|
description="Numero di post a settimana (default: 3 — lun, mer, ven).",
|
|
)
|
|
brand_name: Optional[str] = Field(
|
|
default=None,
|
|
description="Nome del brand/studio — usato nella CTA e nel brand voice.",
|
|
)
|
|
tono: Optional[str] = Field(
|
|
default="diretto e concreto",
|
|
description="Tono di voce per i contenuti generati.",
|
|
)
|
|
unsplash_api_key: Optional[str] = Field(
|
|
default=None,
|
|
description="Chiave API Unsplash. Se configurata, le keyword immagine vengono risolte in URL reali nel CSV.",
|
|
)
|