Import ClientFlow production v4928.1.5.132.4

This commit is contained in:
plx
2026-07-29 13:11:01 +00:00
parent 6445044ac6
commit 261d342057
405 changed files with 48373 additions and 1401 deletions

View File

@@ -9,6 +9,12 @@ class Settings(BaseSettings):
openrouter_model: str = "qwen/qwen3-30b-a3b"
openrouter_url: str = "https://openrouter.ai/api/v1/chat/completions"
# Optional OpenAI Responses API used by the Phase 1 safe email reply agent.
# When disabled or not configured, ClientFlow keeps the existing deterministic/OpenRouter flow.
openai_api_key: str = ""
openai_responses_url: str = "https://api.openai.com/v1/responses"
openai_vector_store_id: str = ""
# ClientFlow requer PostgreSQL. SQLite não suporta JSONB, UUID,
# TIMESTAMPTZ nem os índices usados pelo schema core.
database_url: str
@@ -23,12 +29,34 @@ class Settings(BaseSettings):
# company/fiscal customer. Enable only if this warning proves useful.
clientflow_customer_mismatch_warning_enabled: bool = False
# Automatic CONFIRM_DELIVERY tasks are intentionally disabled. The normal
# cadence starts directly with the commercial follow-up; an operator may
# still schedule a manual delivery check from the opportunity page.
confirm_delivery_automation_enabled: bool = False
chatwoot_write_enabled: bool = False
chatwoot_base_url: str = ""
chatwoot_public_url: str = ""
chatwoot_account_id: str = ""
chatwoot_api_token: str = ""
# Reply assistant: deterministic templates + optional business-aware LLM wording.
clientflow_reply_llm_enabled: bool = False
# When true and LLM is enabled, deterministic intent rules are used only as guardrails.
clientflow_reply_llm_first_enabled: bool = True
clientflow_reply_llm_model: str = ""
clientflow_reply_llm_temperature: float = 0.2
clientflow_reply_llm_max_tokens: int = 700
clientflow_reply_llm_timeout_seconds: int = 20
clientflow_reply_llm_max_context_chars: int = 5000
# Phase 1: safe draft-only email reply agent backed by OpenAI file_search.
clientflow_email_reply_agent_enabled: bool = False
clientflow_email_reply_agent_model: str = "gpt-4.1-mini"
clientflow_email_reply_agent_timeout_seconds: int = 30
clientflow_email_reply_agent_max_results: int = 6
clientflow_email_reply_agent_prompt_version: str = "blif-email-agent-phase1-20260613"
# External operational systems
odoo_enabled: bool = False
odoo_base_url: str = ""
@@ -101,6 +129,26 @@ class Settings(BaseSettings):
settings = Settings()
def is_production_like_env() -> bool:
return str(settings.env or "").strip().lower() in {"prod", "production", "staging"}
if is_production_like_env() and not str(settings.clientflow_admin_token or "").strip():
raise RuntimeError(
"CLIENTFLOW_ADMIN_TOKEN é obrigatório em prod/production/staging."
)
if (
is_production_like_env()
and settings.external_company_lookup_enabled
and str(settings.external_company_lookup_base_url or "").strip()
and not str(settings.external_company_lookup_api_key or "").strip()
):
raise RuntimeError(
"EXTERNAL_COMPANY_LOOKUP_API_KEY é obrigatória quando o lookup externo está ativo em produção."
)
if settings.database_url.strip().lower().startswith("sqlite"):
raise RuntimeError(
"ClientFlow requer PostgreSQL. Defina DATABASE_URL com postgresql+psycopg://..."