Spaces:
Sleeping
Sleeping
File size: 1,097 Bytes
74bb5fe |
1 2 3 4 5 6 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 |
from __future__ import annotations
import os
from pydantic_settings import BaseSettings
from pydantic import Field
class Settings(BaseSettings):
BACKEND_LLM: str = Field(default="llamacpp") # 'llamacpp' | 'openai' | 'groq'
LLAMACPP_MODEL_PATH: str = Field(default="models/qwen2.5-1.5b-instruct-q4_k_m.gguf")
N_CTX: int = 4096
N_THREADS: int = 4
N_GPU_LAYERS: int = 0
ASR_DEVICE: str = "mps" # 'mps' or 'cpu'
TTS_ENGINE: str = "pyttsx3" # 'pyttsx3' | 'say' | 'piper' (later)
OPENAI_API_KEY: str | None = None
GROQ_API_KEY: str | None = None
IS_HF_SPACE: bool = False
DEBUG: bool = True
class Config:
env_file = ".env"
extra = "ignore"
def pretty(self) -> dict:
d = self.model_dump()
if d.get("OPENAI_API_KEY"):
d["OPENAI_API_KEY"] = True
if d.get("GROQ_API_KEY"):
d["GROQ_API_KEY"] = True
return d
_settings: Settings | None = None
def get_settings() -> Settings:
global _settings
if _settings is None:
_settings = Settings()
return _settings |