Full-stack implementation enabling UI-driven management of the 5 AI agent knowledge bases (Legal, Brand Barclays, Brand Barclaycard, Channel Best Practices, Channel Tech Specs). Backend: - 4 new DB models: KnowledgeBase, SourceDocument, SpecVersion, ProcessingJob - Migration 006: creates tables, seeds 5 KB rows, imports existing prompts/*.md as v1 specs - KnowledgeBaseRepository with full CRUD for all 4 tables - LlamaParseService for document parsing, KnowledgeBaseService for pipeline orchestration - ReferenceDocsService updated with DB-backed spec loading + cache invalidation - 11 REST endpoints under /api/knowledge-base (list, detail, upload, delete, process, job status, versions, diff, activate) - StorageService extended with KB document storage Frontend: - TypeScript types for all KB entities (KnowledgeBaseListItem, SourceDocument, ProcessingJob, SpecVersion, DiffResult) - ApiService methods for all KB endpoints including multipart file upload - KnowledgeBase component with 3-level UI: agent grid, detail view (documents + versions tabs), diff viewer - Drag-and-drop file upload, processing progress bar with 3s polling, version comparison - KnowledgeBaseIcon + Sidebar nav item with adminOnly filtering Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
59 lines
2.3 KiB
Python
Executable file
59 lines
2.3 KiB
Python
Executable file
import os
|
|
from pathlib import Path
|
|
from dotenv import load_dotenv
|
|
|
|
# Load environment variables from .env file
|
|
load_dotenv()
|
|
|
|
|
|
class Settings:
|
|
"""Application settings loaded from environment variables."""
|
|
|
|
GEMINI_API_KEY: str = os.getenv("GEMINI_API_KEY", "")
|
|
CORS_ORIGINS: str = os.getenv("CORS_ORIGINS", "http://localhost:3000")
|
|
HOST: str = os.getenv("HOST", "0.0.0.0")
|
|
PORT: int = int(os.getenv("PORT", "8000"))
|
|
|
|
# Reference docs path - defaults to ../reference_docs relative to backend/
|
|
_default_ref_docs = Path(__file__).parent.parent.parent / "reference_docs"
|
|
REFERENCE_DOCS_PATH: str = os.getenv("REFERENCE_DOCS_PATH", str(_default_ref_docs))
|
|
|
|
# Azure AD Configuration for token verification
|
|
AZURE_TENANT_ID: str = os.getenv("AZURE_TENANT_ID", "")
|
|
AZURE_CLIENT_ID: str = os.getenv("AZURE_CLIENT_ID", "")
|
|
|
|
# Auth bypass for development (set to "true" to skip auth)
|
|
DISABLE_AUTH: bool = os.getenv("DISABLE_AUTH", "false").lower() == "true"
|
|
|
|
# Database configuration
|
|
DATABASE_URL: str = os.getenv(
|
|
"DATABASE_URL",
|
|
"postgresql+asyncpg://modcomms:modcomms_dev@localhost:5432/modcomms"
|
|
)
|
|
|
|
# File storage path for uploaded proofs
|
|
_default_storage = Path(__file__).parent.parent.parent / "storage"
|
|
FILE_STORAGE_PATH: str = os.getenv("FILE_STORAGE_PATH", str(_default_storage))
|
|
|
|
# LlamaParse API key (optional - KB processing pipeline disabled if not set)
|
|
LLAMA_CLOUD_API_KEY: str = os.getenv("LLAMA_CLOUD_API_KEY", "")
|
|
|
|
# Mailgun Configuration for support emails
|
|
MAILGUN_API_URL: str = os.getenv("MAILGUN_API_URL", "")
|
|
MAILGUN_API_KEY: str = os.getenv("MAILGUN_API_KEY", "")
|
|
MAILGUN_FROM: str = os.getenv("MAILGUN_FROM", "")
|
|
SUPPORT_EMAIL: str = os.getenv("SUPPORT_EMAIL", "BAICsupport@oliver.agency")
|
|
|
|
def validate(self) -> None:
|
|
"""Validate required settings are present."""
|
|
if not self.GEMINI_API_KEY:
|
|
raise ValueError("GEMINI_API_KEY environment variable is required")
|
|
|
|
if not self.DISABLE_AUTH:
|
|
if not self.AZURE_TENANT_ID:
|
|
raise ValueError("AZURE_TENANT_ID environment variable is required (or set DISABLE_AUTH=true)")
|
|
if not self.AZURE_CLIENT_ID:
|
|
raise ValueError("AZURE_CLIENT_ID environment variable is required (or set DISABLE_AUTH=true)")
|
|
|
|
|
|
settings = Settings()
|