Amaranath commited on
Commit
ef78d53
Β·
verified Β·
1 Parent(s): 5c774e3

Create config.py

Browse files
Files changed (1) hide show
  1. config.py +29 -0
config.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import secrets
3
+ from typing import Optional
4
+
5
+ class Settings:
6
+ def __init__(self):
7
+ # Generate a secure API key if not provided
8
+ self.api_key: str = os.getenv("API_KEY", secrets.token_urlsafe(32))
9
+
10
+ # Generate a separate admin key for sensitive operations
11
+ self.admin_key: str = os.getenv("ADMIN_KEY", secrets.token_urlsafe(32))
12
+
13
+ self.ollama_host: str = os.getenv("OLLAMA_HOST", "127.0.0.1:11434")
14
+ self.app_host: str = os.getenv("APP_HOST", "0.0.0.0")
15
+ self.app_port: int = int(os.getenv("APP_PORT", "7860"))
16
+
17
+ # Print both keys for easy access
18
+ print("=" * 60)
19
+ print("πŸ”‘ AUTHENTICATION KEYS")
20
+ print("=" * 60)
21
+ print(f"πŸ” API Key (for regular usage): {self.api_key}")
22
+ print(f"πŸ”§ Admin Key (for key management): {self.admin_key}")
23
+ print("=" * 60)
24
+ print("🚨 SAVE BOTH KEYS SECURELY!")
25
+ print("πŸ” API Key: Use for all model operations")
26
+ print("πŸ”§ Admin Key: Use for key management and admin operations")
27
+ print("=" * 60)
28
+
29
+ settings = Settings()