Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,10 +11,10 @@ from datetime import datetime, timedelta
|
|
| 11 |
import os
|
| 12 |
|
| 13 |
# Load environment variables for Hugging Face Spaces
|
| 14 |
-
OPENAI_API_KEY = os.getenv("
|
| 15 |
-
DEEPSEEK_API_KEY = os.getenv("
|
| 16 |
-
GOOGLE_CSE_KEYS = os.getenv("
|
| 17 |
-
GOOGLE_CSE_IDS = os.getenv("
|
| 18 |
|
| 19 |
class CitationChecker:
|
| 20 |
def __init__(self):
|
|
@@ -556,32 +556,48 @@ def create_interface():
|
|
| 556 |
with gr.Column(scale=1):
|
| 557 |
gr.Markdown("## π API Configuration")
|
| 558 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 559 |
openai_key = gr.Textbox(
|
| 560 |
label="OpenAI API Key",
|
| 561 |
type="password",
|
| 562 |
-
placeholder="sk-... (
|
| 563 |
-
value=
|
| 564 |
)
|
| 565 |
|
| 566 |
deepseek_key = gr.Textbox(
|
| 567 |
label="DeepSeek API Key (Optional)",
|
| 568 |
type="password",
|
| 569 |
-
placeholder="sk-... (
|
| 570 |
-
value=
|
| 571 |
)
|
| 572 |
|
| 573 |
google_keys = gr.Textbox(
|
| 574 |
label="Google CSE API Keys",
|
| 575 |
-
placeholder="key1,key2,key3 (comma-separated
|
| 576 |
info="Multiple keys for better rate limiting",
|
| 577 |
-
value=
|
| 578 |
)
|
| 579 |
|
| 580 |
google_ids = gr.Textbox(
|
| 581 |
label="Google CSE IDs",
|
| 582 |
-
placeholder="cx1,cx2,cx3 (comma-separated
|
| 583 |
info="Corresponding CSE IDs for each API key",
|
| 584 |
-
value=
|
| 585 |
)
|
| 586 |
|
| 587 |
with gr.Row():
|
|
|
|
| 11 |
import os
|
| 12 |
|
| 13 |
# Load environment variables for Hugging Face Spaces
|
| 14 |
+
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")
|
| 15 |
+
DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY", "")
|
| 16 |
+
GOOGLE_CSE_KEYS = os.getenv("GOOGLE_CSE_KEYS", "") # comma-separated
|
| 17 |
+
GOOGLE_CSE_IDS = os.getenv("GOOGLE_CSE_IDS", "") # comma-separated
|
| 18 |
|
| 19 |
class CitationChecker:
|
| 20 |
def __init__(self):
|
|
|
|
| 556 |
with gr.Column(scale=1):
|
| 557 |
gr.Markdown("## π API Configuration")
|
| 558 |
|
| 559 |
+
# Show status of environment variables without exposing them
|
| 560 |
+
env_status = []
|
| 561 |
+
if OPENAI_API_KEY:
|
| 562 |
+
env_status.append("β
OpenAI API Key (from environment)")
|
| 563 |
+
if DEEPSEEK_API_KEY:
|
| 564 |
+
env_status.append("β
DeepSeek API Key (from environment)")
|
| 565 |
+
if GOOGLE_CSE_KEYS:
|
| 566 |
+
env_status.append("β
Google CSE Keys (from environment)")
|
| 567 |
+
if GOOGLE_CSE_IDS:
|
| 568 |
+
env_status.append("β
Google CSE IDs (from environment)")
|
| 569 |
+
|
| 570 |
+
if env_status:
|
| 571 |
+
gr.Markdown("**π Environment Variables Detected:**\n" + "\n".join(env_status) + "\n\n*Leave fields below empty to use environment variables*")
|
| 572 |
+
else:
|
| 573 |
+
gr.Markdown("**β οΈ No environment variables detected - please enter API keys manually**")
|
| 574 |
+
|
| 575 |
openai_key = gr.Textbox(
|
| 576 |
label="OpenAI API Key",
|
| 577 |
type="password",
|
| 578 |
+
placeholder="sk-... (leave empty to use environment variable)",
|
| 579 |
+
value="" # NEVER pre-fill with actual keys!
|
| 580 |
)
|
| 581 |
|
| 582 |
deepseek_key = gr.Textbox(
|
| 583 |
label="DeepSeek API Key (Optional)",
|
| 584 |
type="password",
|
| 585 |
+
placeholder="sk-... (leave empty to use environment variable)",
|
| 586 |
+
value="" # NEVER pre-fill with actual keys!
|
| 587 |
)
|
| 588 |
|
| 589 |
google_keys = gr.Textbox(
|
| 590 |
label="Google CSE API Keys",
|
| 591 |
+
placeholder="key1,key2,key3 (comma-separated, leave empty to use env var)",
|
| 592 |
info="Multiple keys for better rate limiting",
|
| 593 |
+
value="" # NEVER pre-fill with actual keys!
|
| 594 |
)
|
| 595 |
|
| 596 |
google_ids = gr.Textbox(
|
| 597 |
label="Google CSE IDs",
|
| 598 |
+
placeholder="cx1,cx2,cx3 (comma-separated, leave empty to use env var)",
|
| 599 |
info="Corresponding CSE IDs for each API key",
|
| 600 |
+
value="" # NEVER pre-fill with actual keys!
|
| 601 |
)
|
| 602 |
|
| 603 |
with gr.Row():
|