Update ui_components.py
Browse files- ui_components.py +13 -4
ui_components.py
CHANGED
|
@@ -50,9 +50,10 @@ class UIComponents:
|
|
| 50 |
|
| 51 |
def create_interface(self) -> gr.Blocks:
|
| 52 |
"""Create the main Gradio interface with improved layout"""
|
|
|
|
| 53 |
with gr.Blocks(
|
| 54 |
title="Universal MCP Client - HF Inference Powered",
|
| 55 |
-
theme=
|
| 56 |
fill_height=True,
|
| 57 |
css=CUSTOM_CSS
|
| 58 |
) as demo:
|
|
@@ -67,6 +68,16 @@ class UIComponents:
|
|
| 67 |
self._setup_event_handlers(chatbot, demo)
|
| 68 |
|
| 69 |
return demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
def _create_sidebar(self):
|
| 72 |
"""Create the sidebar with login, provider/model selection, and server management"""
|
|
@@ -102,9 +113,7 @@ class UIComponents:
|
|
| 102 |
"""Create secret input section for Hugging Face API keys"""
|
| 103 |
with gr.Group(elem_classes="login-section"):
|
| 104 |
gr.Markdown("""
|
| 105 |
-
**🔐
|
| 106 |
-
|
| 107 |
-
Paste your API token below. It stays in your browser session only and is not stored.
|
| 108 |
""")
|
| 109 |
self.api_key_box = gr.Textbox(
|
| 110 |
label="HF API Token",
|
|
|
|
| 50 |
|
| 51 |
def create_interface(self) -> gr.Blocks:
|
| 52 |
"""Create the main Gradio interface with improved layout"""
|
| 53 |
+
theme = self._load_theme()
|
| 54 |
with gr.Blocks(
|
| 55 |
title="Universal MCP Client - HF Inference Powered",
|
| 56 |
+
theme=theme,
|
| 57 |
fill_height=True,
|
| 58 |
css=CUSTOM_CSS
|
| 59 |
) as demo:
|
|
|
|
| 68 |
self._setup_event_handlers(chatbot, demo)
|
| 69 |
|
| 70 |
return demo
|
| 71 |
+
|
| 72 |
+
def _load_theme(self):
|
| 73 |
+
"""Load the preferred Gradio theme with fallback handling"""
|
| 74 |
+
try:
|
| 75 |
+
return gr.themes.Theme.from_hub(AppConfig.GRADIO_THEME)
|
| 76 |
+
except Exception as exc:
|
| 77 |
+
logger.warning(f"Custom theme load failed: {exc}; using fallback theme")
|
| 78 |
+
fallback_name = getattr(AppConfig, "GRADIO_FALLBACK_THEME", "ocean")
|
| 79 |
+
fallback_attr = getattr(gr.themes, fallback_name.title(), gr.themes.Ocean)
|
| 80 |
+
return fallback_attr()
|
| 81 |
|
| 82 |
def _create_sidebar(self):
|
| 83 |
"""Create the sidebar with login, provider/model selection, and server management"""
|
|
|
|
| 113 |
"""Create secret input section for Hugging Face API keys"""
|
| 114 |
with gr.Group(elem_classes="login-section"):
|
| 115 |
gr.Markdown("""
|
| 116 |
+
**🔐 HF Token**
|
|
|
|
|
|
|
| 117 |
""")
|
| 118 |
self.api_key_box = gr.Textbox(
|
| 119 |
label="HF API Token",
|