| from __future__ import annotations | |
| import inspect | |
| from pathlib import Path | |
| import gradio as gr | |
| from time_machine.application.blank_services import BlankExperienceServices | |
| ASSET_DIR = Path(__file__).resolve().parent / "assets" | |
| BLANK_CSS = """ | |
| :root, body, .gradio-container, main { | |
| background: #020305 !important; | |
| } | |
| footer, .footer { | |
| display: none !important; | |
| } | |
| .gradio-container { | |
| min-height: 100vh; | |
| padding: 0 !important; | |
| } | |
| .gradio-container .contain { | |
| max-width: none !important; | |
| padding: 0 !important; | |
| } | |
| .gradio-container .block, | |
| .gradio-container .form, | |
| .gradio-container .prose { | |
| border: 0 !important; | |
| background: transparent !important; | |
| padding: 0 !important; | |
| margin: 0 !important; | |
| } | |
| """ | |
| def create_blank_app(services: BlankExperienceServices) -> gr.Blocks: | |
| intro_css = (ASSET_DIR / "intro.css").read_text(encoding="utf-8") | |
| intro_html = (ASSET_DIR / "intro.html").read_text(encoding="utf-8") | |
| intro_js = (ASSET_DIR / "intro.js").read_text(encoding="utf-8") | |
| blocks_kwargs = { | |
| "title": "Trans-Temporal Express", | |
| } | |
| if "fill_height" in inspect.signature(gr.Blocks).parameters: | |
| blocks_kwargs["fill_height"] = True | |
| if "head" in inspect.signature(gr.Blocks).parameters: | |
| blocks_kwargs["head"] = f"<script>{intro_js}</script>" | |
| with gr.Blocks(**blocks_kwargs) as demo: | |
| gr.HTML(f"<style>{BLANK_CSS}</style><style>{intro_css}</style>{intro_html}", elem_id="blank-style-anchor") | |
| gr.State( | |
| { | |
| "adapter_profile": services.adapter_profile, | |
| "model_budget": { | |
| "enabled_parameters_billion": services.model_budget.enabled_parameters_billion, | |
| "largest_enabled_parameters_billion": services.model_budget.largest_enabled_parameters_billion, | |
| "parameter_limit_billion": services.model_budget.parameter_limit_billion, | |
| }, | |
| } | |
| ) | |
| return demo.queue() | |