Spaces:
Paused
Paused
Create config.py
Browse files
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()
|