| from __future__ import annotations |
|
|
| from typing import cast |
|
|
| import gradio as gr |
|
|
| from core.app_logging import configure_app_logging |
| from core.deployment import current_policy |
| from models.model_catalog import load_model_catalog |
| from ui.agent_tab import build_agent_tab |
| from ui.chat_tab import build_chat_tab |
| from ui.dataset_tab import build_dataset_tab |
| from ui.export_tab import build_export_tab |
| from ui.notes_tab import build_notes_tab |
| from ui.status_tab import build_status_tab |
| from ui.traces_tab import build_traces_tab |
| from ui.train_tab import build_train_tab |
| from ui.vision_tab import build_vision_tab |
| from ui.vllm_tab import build_vllm_tab |
|
|
| APP_THEME = gr.themes.Soft(primary_hue="teal", neutral_hue="slate") |
| APP_CSS = """ |
| .app-title { |
| margin-bottom: 0.25rem; |
| } |
| |
| .gradio-container { |
| max-width: 1180px !important; |
| } |
| |
| .tabs { |
| overflow-x: auto; |
| } |
| |
| button { |
| min-height: 2.5rem; |
| } |
| |
| textarea, |
| input, |
| .wrap { |
| max-width: 100%; |
| } |
| |
| @media (max-width: 720px) { |
| .gradio-container { |
| padding-left: 0.75rem !important; |
| padding-right: 0.75rem !important; |
| } |
| |
| .app-title h1 { |
| font-size: 1.55rem; |
| line-height: 1.2; |
| } |
| } |
| """ |
|
|
|
|
| def build_app() -> gr.Blocks: |
| configure_app_logging() |
| policy = current_policy() |
| catalog = load_model_catalog("config/models.yaml") |
|
|
| with gr.Blocks(title="OpenBMB Local AI Workbench", analytics_enabled=False) as demo: |
| gr.Markdown( |
| """ |
| # OpenBMB Local AI Workbench |
| Real small-model experimentation for Gradio + Hugging Face Spaces. |
| """, |
| elem_classes=["app-title"], |
| ) |
| if policy.is_space: |
| gr.Markdown( |
| "Deployment mode: Space. Placeholder and demo inference are disabled; " |
| "select a configured real backend before running model calls." |
| ) |
|
|
| with gr.Tabs(): |
| with gr.Tab("Chat"): |
| build_chat_tab(catalog, policy) |
| with gr.Tab("Vision"): |
| build_vision_tab(catalog, policy) |
| with gr.Tab("Dataset"): |
| build_dataset_tab() |
| with gr.Tab("Train"): |
| build_train_tab() |
| with gr.Tab("vLLM"): |
| build_vllm_tab(catalog) |
| with gr.Tab("Export"): |
| build_export_tab(catalog) |
| with gr.Tab("Field Notes"): |
| build_notes_tab(catalog) |
| with gr.Tab("Traces"): |
| build_traces_tab() |
| with gr.Tab("Agent"): |
| build_agent_tab() |
| with gr.Tab("Status"): |
| build_status_tab(catalog, policy) |
|
|
| return cast(gr.Blocks, demo) |
|
|
|
|
| if __name__ == "__main__": |
| build_app().launch( |
| server_port=7860, |
| share=False, |
| theme=APP_THEME, |
| css=APP_CSS, |
| mcp_server=True, |
| ) |
|
|