Spaces:
Runtime error
Runtime error
Update api/config.py
Browse files- api/config.py +54 -47
api/config.py
CHANGED
|
@@ -1,52 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
-
### config.py
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
from typing import Optional
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
@lru_cache(maxsize=1)
|
| 50 |
-
def get_settings() -> Settings:
|
| 51 |
-
"""Retorna instância singleton de Settings."""
|
| 52 |
-
return Settings()
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
API Configuration
|
| 3 |
+
Environment variables and settings
|
| 4 |
+
"""
|
| 5 |
+
from pydantic_settings import BaseSettings
|
| 6 |
+
from pydantic import Field
|
| 7 |
+
from typing import Optional
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
import os
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
+
class Settings(BaseSettings):
|
| 13 |
+
"""API Configuration Settings"""
|
|
|
|
| 14 |
|
| 15 |
+
APP_NAME: str = "para.AI API"
|
| 16 |
+
APP_VERSION: str = "3.0.0"
|
| 17 |
+
DEBUG: bool = os.getenv("DEBUG", "true").lower() == "true"
|
| 18 |
|
| 19 |
+
API_HOST: str = os.getenv("API_HOST", "0.0.0.0")
|
| 20 |
+
API_PORT: int = int(os.getenv("API_PORT", "7860"))
|
| 21 |
|
| 22 |
+
# Paths
|
| 23 |
+
BASE_DIR: Path = Path(__file__).parent
|
| 24 |
+
STORAGE_DIR: Path = BASE_DIR / "storage"
|
| 25 |
+
TEMP_DIR: Path = STORAGE_DIR / "temp"
|
| 26 |
+
OUTPUT_DIR: Path = STORAGE_DIR / "output"
|
| 27 |
+
DOWNLOADS_DIR: Path = STORAGE_DIR / "downloads"
|
| 28 |
+
|
| 29 |
+
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql://user:pass@localhost:5432/paraai")
|
| 30 |
+
REDIS_URL: str = os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
| 31 |
+
|
| 32 |
+
LLM_MODEL: str = os.getenv("LLM_MODEL", "gemini-1.5-pro-001")
|
| 33 |
+
LLM_TEMPERATURE: float = float(os.getenv("LLM_TEMPERATURE", "1.3"))
|
| 34 |
+
LLM_MAX_TOKENS: int = int(os.getenv("LLM_MAX_TOKENS", "14000"))
|
| 35 |
+
|
| 36 |
+
GEMINI_API_KEY: Optional[str] = os.getenv("GEMINI_API_KEY")
|
| 37 |
+
|
| 38 |
+
MAX_WORKERS: int = int(os.getenv("MAX_WORKERS", "10"))
|
| 39 |
+
BATCH_SIZE: int = int(os.getenv("BATCH_SIZE", "100"))
|
| 40 |
+
|
| 41 |
+
CORS_ORIGINS: list[str] = [
|
| 42 |
+
"http://localhost:7860",
|
| 43 |
+
"https://*.hf.space",
|
| 44 |
+
"*"
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
| 48 |
+
|
| 49 |
+
model_config = {
|
| 50 |
+
"env_file": ".env",
|
| 51 |
+
"case_sensitive": True
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
settings = Settings()
|
| 56 |
+
|
| 57 |
+
# Criar diretórios de storage
|
| 58 |
+
for directory in [settings.TEMP_DIR, settings.OUTPUT_DIR, settings.DOWNLOADS_DIR]:
|
| 59 |
+
directory.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|