Commit
Β·
27a0645
1
Parent(s):
a70ff2b
fix: Settings layout
Browse files
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 |
-
|
| 1597 |
-
|
| 1598 |
-
| Component | Status |
|
| 1599 |
-
|-----------|--------|
|
| 1600 |
-
| **Google Gemini API** | {gemini_display} |
|
| 1601 |
-
| **HuggingFace Token** | {hf_display} |
|
| 1602 |
|
| 1603 |
-
|
| 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 |
-
|
| 1626 |
-
|
| 1627 |
-
|
| 1628 |
-
|
| 1629 |
-
|
| 1630 |
-
|
| 1631 |
-
|
| 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.
|
| 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 |
-
|
| 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
|