feat(01-03): API routers (calendar, generate, export, settings) e wiring main.py
- schemas/settings.py: Settings pydantic model con api_key, llm_model, nicchie_attive, tono
- routers/calendar.py: POST /api/calendar/generate, GET /api/calendar/formats
- routers/generate.py: POST /api/generate/bulk (202 + job_id), GET /job/{job_id}/status (polling), GET /job/{job_id}, POST /single
- routers/export.py: GET /api/export/{job_id}/csv (originale), POST /api/export/{job_id}/csv (modifiche inline)
- routers/settings.py: GET /api/settings/status (api_key_configured), GET /api/settings, PUT /api/settings
- main.py: include_router x4 PRIMA di SPAStaticFiles, copia prompt default al primo avvio
This commit is contained in:
50
backend/schemas/settings.py
Normal file
50
backend/schemas/settings.py
Normal file
@@ -0,0 +1,50 @@
|
||||
"""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.",
|
||||
)
|
||||
Reference in New Issue
Block a user