ReplyFlow / app /config.py
nvikou's picture
Fix HF startup: JSON store, local seed, non-blocking lifespan
a6e51ba verified
Raw History Blame Contribute Delete
2.11 kB
"""Application settings loaded from environment."""
from functools import lru_cache
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""Runtime configuration for ReplyFlow."""
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore",
)
app_name: str = "ReplyFlow"
app_env: str = "production"
secret_key: str = "change-me"
public_base_url: str = "http://localhost:7860"
database_url: str = (
"sqlite+aiosqlite:///./data/db/replyflow.db"
)
chroma_path: str = "./data/chroma"
knowledge_path: str = "./data/knowledge"
# Always use JSON fallback on Spaces (no Chroma).
use_json_store: bool = True
# Seed with local embeddings so startup never waits on OpenAI.
seed_local_embeddings: bool = True
openai_api_key: str = ""
openai_model: str = "gpt-4o-mini"
openai_embedding_model: str = "text-embedding-3-small"
calcom_api_key: str = ""
calcom_event_type_id: str = ""
calcom_username: str = ""
whatsapp_token: str = ""
whatsapp_phone_number_id: str = ""
whatsapp_verify_token: str = "replyflow-verify"
whatsapp_app_secret: str = ""
handoff_webhook_url: str = ""
demo_business_name: str = "Nordic Paper Solutions"
demo_timezone: str = "Europe/Paris"
@property
def has_openai(self) -> bool:
"""True when an OpenAI API key is configured."""
return bool(self.openai_api_key.strip())
@property
def has_calcom(self) -> bool:
"""True when Cal.com credentials are configured."""
return bool(
self.calcom_api_key.strip()
and self.calcom_event_type_id.strip()
)
@property
def has_whatsapp(self) -> bool:
"""True when WhatsApp credentials are configured."""
return bool(
self.whatsapp_token.strip()
and self.whatsapp_phone_number_id.strip()
)
@lru_cache
def get_settings() -> Settings:
"""Return cached settings instance."""
return Settings()