kshitijthakkar commited on
Commit
27a0645
Β·
1 Parent(s): a70ff2b

fix: Settings layout

Browse files
Files changed (1) hide show
  1. app.py +24 -95
app.py CHANGED
@@ -1545,44 +1545,6 @@ def create_gradio_ui():
1545
  """)
1546
 
1547
  with gr.Tab("βš™οΈ Settings"):
1548
- gr.Markdown("""
1549
- # βš™οΈ API Configuration
1550
-
1551
- ## Overview
1552
-
1553
- TraceMind MCP Server operates with **pre-configured API keys** from HuggingFace Spaces Secrets, enabling immediate use without additional setup.
1554
-
1555
- **For Judges & Advanced Users**: Override default credentials with your own API keys to:
1556
- - Avoid rate limits during extensive testing
1557
- - Track usage independently
1558
- - Ensure uninterrupted evaluation access
1559
-
1560
- ---
1561
-
1562
- ## Configuration Options
1563
-
1564
- **Default Mode** (Recommended)
1565
- - Uses HuggingFace Spaces Secrets
1566
- - No configuration required
1567
- - Suitable for most evaluations
1568
-
1569
- **Custom Mode** (Optional)
1570
- - Session-scoped overrides
1571
- - Your keys take precedence
1572
- - Active until browser refresh
1573
-
1574
- ---
1575
-
1576
- ## Security
1577
-
1578
- - βœ… **Session-only storage** - Keys never persisted to disk
1579
- - βœ… **No API exposure** - Configuration endpoint disabled (`api_name=False`)
1580
- - βœ… **HTTPS encrypted** - All communications secured
1581
- - βœ… **Privacy-first** - Key status displayed without revealing characters
1582
-
1583
- ---
1584
- """)
1585
-
1586
  # Show current key status (fully masked for security)
1587
  current_gemini = os.environ.get("GEMINI_API_KEY", "")
1588
  current_hf = os.environ.get("HF_TOKEN", "")
@@ -1590,46 +1552,31 @@ def create_gradio_ui():
1590
  gemini_display = "βœ… Configured" if current_gemini else "❌ Not configured"
1591
  hf_display = "βœ… Configured" if current_hf else "❌ Not configured"
1592
 
1593
- status_badge = "βœ… **Active Configuration**: HuggingFace Spaces Secrets" if (current_gemini and current_hf) else "⚠️ **Status**: Incomplete configuration"
1594
-
1595
  gr.Markdown(f"""
1596
- ## Current Status
1597
-
1598
- | Component | Status |
1599
- |-----------|--------|
1600
- | **Google Gemini API** | {gemini_display} |
1601
- | **HuggingFace Token** | {hf_display} |
1602
 
1603
- {status_badge}
1604
 
1605
- ---
1606
  """)
1607
 
1608
- gr.Markdown("""
1609
- ## Custom API Keys
1610
-
1611
- **Optional**: Override default credentials with your own keys for this session.
1612
- """)
1613
-
1614
- with gr.Row():
1615
- with gr.Column():
1616
- gemini_api_key_input = gr.Textbox(
1617
- label="Google Gemini API Key (Optional)",
1618
- placeholder="Leave empty for defaults or enter: AIza...",
1619
- type="password",
1620
- value="",
1621
- info="Free tier: 1,500 requests/day β€’ Get key: https://ai.google.dev/"
1622
- )
1623
-
1624
  with gr.Row():
1625
- with gr.Column():
1626
- hf_token_input = gr.Textbox(
1627
- label="HuggingFace Token (Optional)",
1628
- placeholder="Leave empty for defaults or enter: hf_...",
1629
- type="password",
1630
- value="",
1631
- info="Permissions: Read (view) or Write (full access) β€’ Get token: https://huggingface.co/settings/tokens"
1632
- )
 
 
 
 
 
 
 
 
1633
 
1634
  with gr.Row():
1635
  save_keys_btn = gr.Button("πŸ’Ύ Apply Configuration", variant="primary", size="lg")
@@ -1637,31 +1584,13 @@ def create_gradio_ui():
1637
 
1638
  settings_status = gr.Markdown("")
1639
 
1640
- gr.Markdown("""
1641
- ---
1642
-
1643
- ## API Key Setup Guide
1644
-
1645
- <details>
1646
- <summary><b>πŸ“– Click to expand setup instructions</b></summary>
1647
-
1648
- ### Google Gemini API
1649
-
1650
- 1. Visit [Google AI Studio](https://ai.google.dev/)
1651
- 2. Generate API key (starts with `AIza`)
1652
- 3. **Free tier**: 1,500 requests/day
1653
-
1654
- ### HuggingFace Token
1655
-
1656
- 1. Visit [HuggingFace Tokens](https://huggingface.co/settings/tokens)
1657
- 2. Create token with **Read** (view datasets) or **Write** (upload datasets) permissions
1658
- 3. Token starts with `hf_`
1659
-
1660
- </details>
1661
 
1662
- ---
1663
 
1664
- **Note**: Custom keys are session-scoped and cleared on page refresh.
1665
  """)
1666
 
1667
  # Event handlers for Settings tab
 
1545
  """)
1546
 
1547
  with gr.Tab("βš™οΈ Settings"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1548
  # Show current key status (fully masked for security)
1549
  current_gemini = os.environ.get("GEMINI_API_KEY", "")
1550
  current_hf = os.environ.get("HF_TOKEN", "")
 
1552
  gemini_display = "βœ… Configured" if current_gemini else "❌ Not configured"
1553
  hf_display = "βœ… Configured" if current_hf else "❌ Not configured"
1554
 
 
 
1555
  gr.Markdown(f"""
1556
+ ### API Configuration
 
 
 
 
 
1557
 
1558
+ **Current Status**: Gemini API: {gemini_display} β€’ HuggingFace Token: {hf_display}
1559
 
1560
+ The server is pre-configured with API keys from HuggingFace Spaces Secrets. Optionally override with your own keys for this session.
1561
  """)
1562
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1563
  with gr.Row():
1564
+ gemini_api_key_input = gr.Textbox(
1565
+ label="Google Gemini API Key (Optional)",
1566
+ placeholder="AIza...",
1567
+ type="password",
1568
+ value="",
1569
+ info="Free tier: 1,500 requests/day",
1570
+ scale=1
1571
+ )
1572
+ hf_token_input = gr.Textbox(
1573
+ label="HuggingFace Token (Optional)",
1574
+ placeholder="hf_...",
1575
+ type="password",
1576
+ value="",
1577
+ info="Read or Write permissions",
1578
+ scale=1
1579
+ )
1580
 
1581
  with gr.Row():
1582
  save_keys_btn = gr.Button("πŸ’Ύ Apply Configuration", variant="primary", size="lg")
 
1584
 
1585
  settings_status = gr.Markdown("")
1586
 
1587
+ with gr.Accordion("πŸ“– Setup Instructions", open=False):
1588
+ gr.Markdown("""
1589
+ **Google Gemini API**: Get your key at [Google AI Studio](https://ai.google.dev/) (Free: 1,500 requests/day)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1590
 
1591
+ **HuggingFace Token**: Create at [HuggingFace Settings](https://huggingface.co/settings/tokens) (Read or Write permissions)
1592
 
1593
+ **Security**: Custom keys are session-only and cleared on page refresh.
1594
  """)
1595
 
1596
  # Event handlers for Settings tab