yuvrajyadav commited on
Commit
dd6ede4
Β·
verified Β·
1 Parent(s): fd28f6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -12
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("OaPI1")
15
- DEEPSEEK_API_KEY = os.getenv("DAPI")
16
- GOOGLE_CSE_KEYS = os.getenv("API1") # comma-separated
17
- GOOGLE_CSE_IDS = os.getenv("CX1") # comma-separated
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-... (or set OPENAI_API_KEY environment variable)",
563
- value=OPENAI_API_KEY if OPENAI_API_KEY else ""
564
  )
565
 
566
  deepseek_key = gr.Textbox(
567
  label="DeepSeek API Key (Optional)",
568
  type="password",
569
- placeholder="sk-... (or set DEEPSEEK_API_KEY environment variable)",
570
- value=DEEPSEEK_API_KEY if DEEPSEEK_API_KEY else ""
571
  )
572
 
573
  google_keys = gr.Textbox(
574
  label="Google CSE API Keys",
575
- placeholder="key1,key2,key3 (comma-separated) or set GOOGLE_CSE_KEYS env var",
576
  info="Multiple keys for better rate limiting",
577
- value=GOOGLE_CSE_KEYS if GOOGLE_CSE_KEYS else ""
578
  )
579
 
580
  google_ids = gr.Textbox(
581
  label="Google CSE IDs",
582
- placeholder="cx1,cx2,cx3 (comma-separated) or set GOOGLE_CSE_IDS env var",
583
  info="Corresponding CSE IDs for each API key",
584
- value=GOOGLE_CSE_IDS if GOOGLE_CSE_IDS else ""
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():