Files
trustos/backend/app/core/config.py
drjones 08b12e2ce2
Some checks failed
Deploy / deploy (push) Has been cancelled
Deploy / docker-build (push) Has been cancelled
Test / backend-test (push) Has been cancelled
Test / frontend-test (push) Has been cancelled
Test / security-scan (push) Has been cancelled
Wire AI features to Claude (claude-sonnet-5); fix key detection + retired model
The Anthropic path could never activate: it gated on
`not ANTHROPIC_API_KEY.startswith("sk-ant-")`, but real Anthropic keys start
with `sk-ant-`, so any real key was treated as a placeholder and every request
fell back to mock. It also targeted the retired `claude-3-haiku-20240307`.

- ai_translator.py: add `_real_key()` placeholder detection (rejects `sk-ant-...`,
  `changeme`, `your-`, etc. — accepts real secrets), centralize provider gating
  in `_ai_enabled()`, and point all three AI features (finding translation,
  security coach, attack-path narrative) at `claude-sonnet-5` with thinking
  disabled for fast structured output. OpenAI kept as a secondary provider.
- config.py / .env.example: default AI_PROVIDER to anthropic.

Mock mode still works with no key configured; dropping in a real
ANTHROPIC_API_KEY now actually enables live Claude.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 17:20:31 +00:00

39 lines
1.1 KiB
Python

from pydantic_settings import BaseSettings
from pydantic import field_validator
from typing import Optional
class Settings(BaseSettings):
PROJECT_NAME: str = "TrustOS"
VERSION: str = "0.1.0"
API_V1_STR: str = "/api/v1"
DATABASE_URL: str = "postgresql+asyncpg://trustos:trustos_dev@localhost:5432/trustos"
SYNC_DATABASE_URL: str = "postgresql://trustos:trustos_dev@localhost:5432/trustos"
SECRET_KEY: str = "dev-secret-key-change-in-production"
ALGORITHM: str = "HS256"
CORS_ORIGINS: Optional[str] = None # comma-separated extra allowed origins
ACCESS_TOKEN_EXPIRE_MINUTES: int = 480
AI_PROVIDER: str = "anthropic"
OPENAI_API_KEY: Optional[str] = None
ANTHROPIC_API_KEY: Optional[str] = None
HIBP_API_KEY: Optional[str] = None
NVD_API_KEY: Optional[str] = None
STORAGE_PATH: str = "/app/storage"
SMTP_HOST: Optional[str] = None
SMTP_PORT: int = 587
SMTP_USER: Optional[str] = None
SMTP_PASS: Optional[str] = None
class Config:
env_file = ".env"
case_sensitive = True
settings = Settings()