Spaces:
Running on Zero
Running on Zero
File size: 2,833 Bytes
7f9dfed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | 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,
)
|