File size: 2,304 Bytes
7ddb64a
9b0ce22
7ddb64a
 
9b0ce22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7ddb64a
9b0ce22
 
 
7ddb64a
 
9b0ce22
 
 
 
 
 
 
7ddb64a
9b0ce22
 
 
 
 
7ddb64a
9b0ce22
 
7ddb64a
 
9b0ce22
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from pydantic_settings import BaseSettings
from pydantic import BaseModel
import os


class ServerConfig(BaseModel):
    port: int = 5050 
    host: str = "0.0.0.0"

class DatabaseConfig(BaseModel):
    name: str = "medical_diagnosis"
    host: str = "localhost"
    driver: str = "postgresql"
    user: str = "user"
    password: str = "password"

class BucketConfig(BaseModel):
    """Hugging Face bucket configuration for user and conversation storage"""
    repo_id: str = "ryanxely/HealthCare-Storage"
    repo_type: str = "space"
    bucket_path: str = "data/"
    
    # Storage paths in bucket
    users_file: str = "data/users.jsonl"
    conversations_base: str = "data/conversations/"

class LLMConfig(BaseModel):
    # Endpoints
    hf_url: str = "https://router.huggingface.co/v1/chat/completions"
    groq_url: str = "https://api.groq.com/openai/v1/chat/completions"
    groq_whisper_url: str = "https://api.groq.com/openai/v1/audio/transcriptions"


    # API Keys
    hf_token: str = os.environ.get("HF_TOKEN", "")
    groq_token: str = os.environ.get("GROQ_TOKEN", "")

    # Models
    ocr_model: str = "meta-llama/llama-4-scout-17b-16e-instruct"
    chat_model: str = "meta-llama/llama-4-scout-17b-16e-instruct"
    whisper_model: str = "whisper-large-v3-turbo"

    # Generation defaults
    max_tokens: int = 1024
    temperature: float = 0.7
    ocr_temperature: float = 0.1 


# ── Main settings (env-driven) ────────────────────────────────────────────────

class Settings(BaseSettings):
    # Tokens — set these in HF Space Secrets
    secret_key: str = os.environ.get("SECRET_KEY", "your-secret-key-change-in-production")
    hf_token: str = os.environ.get("HF_TOKEN", "")
    model_path: str = ""

    # Runtime flags
    debug_mode: bool = False
    robust_mode: bool = True

    # Auth settings
    jwt_algorithm: str = "HS256"
    jwt_expiration_hours: int = 24

    # Nested configs
    server: ServerConfig = ServerConfig()
    database: DatabaseConfig = DatabaseConfig()
    llm: LLMConfig = LLMConfig()
    bucket: BucketConfig = BucketConfig()

    class Config:
        env_file = ".env"          # loads a local .env file when running locally


settings = Settings()