Spaces:
Running
Running
update
Browse files
app.py
CHANGED
|
@@ -58,19 +58,6 @@ def setup_environment():
|
|
| 58 |
if not api_key:
|
| 59 |
print("βΉοΈ NVIDIA_API_KEY not found. For local development, create a .env file")
|
| 60 |
print(" or set the environment variable manually.")
|
| 61 |
-
else:
|
| 62 |
-
print(f"β
NVIDIA_API_KEY found locally (length: {len(api_key)})")
|
| 63 |
-
print(f" Key starts with: {api_key[:8]}...")
|
| 64 |
-
print(f" Key ends with: ...{api_key[-4:]}")
|
| 65 |
-
print(f" Key is all uppercase: {'Yes' if api_key.isupper() else 'No'}")
|
| 66 |
-
|
| 67 |
-
# Check for common API key patterns
|
| 68 |
-
if api_key.startswith('nvapi-'):
|
| 69 |
-
print(" β
Key format appears correct (starts with 'nvapi-')")
|
| 70 |
-
elif api_key.startswith('nv-'):
|
| 71 |
-
print(" β
Key format appears correct (starts with 'nv-')")
|
| 72 |
-
else:
|
| 73 |
-
print(" β οΈ Key format may be incorrect (should start with 'nvapi-' or 'nv-')")
|
| 74 |
|
| 75 |
def main():
|
| 76 |
"""Main function to launch the application"""
|
|
|
|
| 58 |
if not api_key:
|
| 59 |
print("βΉοΈ NVIDIA_API_KEY not found. For local development, create a .env file")
|
| 60 |
print(" or set the environment variable manually.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
def main():
|
| 63 |
"""Main function to launch the application"""
|
demo.py
CHANGED
|
@@ -105,23 +105,6 @@ def initialize_nvidia_client():
|
|
| 105 |
print(" For Hugging Face Spaces: Set NVIDIA_API_KEY in Repository Secrets")
|
| 106 |
return None
|
| 107 |
else:
|
| 108 |
-
# Validate the API key format
|
| 109 |
-
print("π Validating API key format...")
|
| 110 |
-
validation = validate_api_key(api_key)
|
| 111 |
-
|
| 112 |
-
if not validation['valid']:
|
| 113 |
-
print("β API key validation failed:")
|
| 114 |
-
for issue in validation['issues']:
|
| 115 |
-
print(f" - {issue}")
|
| 116 |
-
print(f" Key preview: {api_key[:8]}...{api_key[-4:]}")
|
| 117 |
-
print(" Please check your API key format and try again.")
|
| 118 |
-
return None
|
| 119 |
-
|
| 120 |
-
print("β
API key format validation passed")
|
| 121 |
-
print(f" Key format: {'β
' if validation['format_ok'] else 'β'}")
|
| 122 |
-
print(f" Key length: {'β
' if validation['length_ok'] else 'β'}")
|
| 123 |
-
print(f" Key charset: {'β
' if validation['charset_ok'] else 'β'}")
|
| 124 |
-
|
| 125 |
try:
|
| 126 |
client = OpenAI(
|
| 127 |
base_url=NVIDIA_BASE_URL,
|
|
|
|
| 105 |
print(" For Hugging Face Spaces: Set NVIDIA_API_KEY in Repository Secrets")
|
| 106 |
return None
|
| 107 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
try:
|
| 109 |
client = OpenAI(
|
| 110 |
base_url=NVIDIA_BASE_URL,
|