Bromeo777 commited on
Commit
b41fceb
·
verified ·
1 Parent(s): 9692b89

Add app\core\config.py

Browse files
Files changed (1) hide show
  1. app//core//config.py +84 -0
app//core//config.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app/core/config.py
2
+ # Final Version: Configured for Romeo AI + Hugging Face Storage (SQLite)
3
+ # Timestamp: 2026-03-15
4
+
5
+ import json
6
+ from typing import List, Union, Optional
7
+ from pydantic import AnyHttpUrl, field_validator
8
+ from pydantic_settings import BaseSettings
9
+
10
+ class Settings(BaseSettings):
11
+ """
12
+ Romeo AI Research Assistant Configuration.
13
+ Aggregates environment-specific variables for secure Hugging Face deployment.
14
+ """
15
+
16
+ # Base Application Settings
17
+ PROJECT_NAME: str = "Romeo AI Research Assistant"
18
+ SERVER_HOST: str = "http://localhost:8000"
19
+ API_V1_STR: str = "/api/v1"
20
+ SECRET_KEY: str = "romeo-ai-secret-key-2026-change-this"
21
+ ALGORITHM: str = "HS256"
22
+ ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7
23
+
24
+ # Security & Logging
25
+ DEBUG: bool = False
26
+ LOG_LEVEL: str = "INFO"
27
+ ADMIN_EMAIL: str = "admin@romeo-research.example.com"
28
+
29
+ # Database Configuration (Async SQLite mapped to Docker /data folder)
30
+ DATABASE_URL: str = "sqlite+aiosqlite:///./data/romeo_research.db"
31
+ DB_ECHO: bool = False
32
+
33
+ @property
34
+ def SQLALCHEMY_DATABASE_URI(self) -> str:
35
+ """Dynamically return the SQLite connection string."""
36
+ return self.DATABASE_URL
37
+
38
+ # 🔥 Hugging Face Sync Settings
39
+ HF_TOKEN: Optional[str] = None
40
+ HF_DATASET_REPO: str = "" # You will set this in HF Variables (e.g., "YourHFUsername/romeo-database")
41
+
42
+ # Vector Store Configuration
43
+ VECTOR_STORE_TYPE: str = "local"
44
+ VERITAS_LOCAL_INDEX_PATH: str = "./data/veritas_index"
45
+
46
+ # CORS Configuration
47
+ BACKEND_CORS_ORIGINS: List[Union[str, AnyHttpUrl]] = ["*"]
48
+
49
+ @field_validator("BACKEND_CORS_ORIGINS", mode="before")
50
+ @classmethod
51
+ def assemble_cors_origins(cls, v: Optional[Union[str, List[str]]]) -> List[str]:
52
+ if v is None or v == "":
53
+ return ["*"]
54
+
55
+ if isinstance(v, list):
56
+ return [str(i) for i in v if i]
57
+
58
+ if isinstance(v, str):
59
+ v = v.strip()
60
+ if not v:
61
+ return ["*"]
62
+
63
+ if v == "*":
64
+ return ["*"]
65
+
66
+ if v.startswith("["):
67
+ try:
68
+ parsed = json.loads(v)
69
+ if isinstance(parsed, list):
70
+ return [str(item) for item in parsed if item]
71
+ return [str(parsed)] if parsed else ["*"]
72
+ except json.JSONDecodeError:
73
+ return [v] if v else ["*"]
74
+
75
+ origins = [i.strip() for i in v.split(",") if i.strip()]
76
+ return origins if origins else ["*"]
77
+
78
+ raise ValueError(f"Invalid CORS origins format: {v}")
79
+
80
+ class Config:
81
+ case_sensitive = True
82
+ env_file = ".env"
83
+
84
+ settings = Settings()