File size: 1,097 Bytes
253f4ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import secrets
from typing import Optional

class Settings:
    def __init__(self):
        # Generate a secure API key if not provided
        self.api_key: str = os.getenv("API_KEY", secrets.token_urlsafe(32))

        # Generate a separate admin key for sensitive operations
        self.admin_key: str = os.getenv("ADMIN_KEY", secrets.token_urlsafe(32))

        self.ollama_host: str = os.getenv("OLLAMA_HOST", "127.0.0.1:11434")
        self.app_host: str = os.getenv("APP_HOST", "0.0.0.0")
        self.app_port: int = int(os.getenv("APP_PORT", "7860"))

        # Print both keys for easy access
        print("=" * 60)
        print("πŸ”‘ AUTHENTICATION KEYS")
        print("=" * 60)
        print(f"πŸ” API Key (for regular usage): {self.api_key}")
        print(f"πŸ”§ Admin Key (for key management): {self.admin_key}")
        print("=" * 60)
        print("🚨 SAVE BOTH KEYS SECURELY!")
        print("πŸ” API Key: Use for all model operations")
        print("πŸ”§ Admin Key: Use for key management and admin operations")
        print("=" * 60)

settings = Settings()