|
|
import gradio as gr |
|
|
import time |
|
|
|
|
|
|
|
|
def start_container(): |
|
|
time.sleep(1) |
|
|
return "Container started successfully!" |
|
|
|
|
|
def stop_container(): |
|
|
time.sleep(1) |
|
|
return "Container stopped successfully!" |
|
|
|
|
|
def load_model(model_name): |
|
|
return f"Model {model_name} loaded successfully!" |
|
|
|
|
|
def process_text(input_text): |
|
|
return f"Processed: {input_text}" |
|
|
|
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
gr.Markdown("# π DevContainer Studio - Live AI Development") |
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(): |
|
|
gr.Markdown("## βοΈ Container Controls") |
|
|
start_btn = gr.Button("π Start Container") |
|
|
stop_btn = gr.Button("π Stop Container") |
|
|
status = gr.Textbox("Status: Stopped", label="Container Status") |
|
|
|
|
|
gr.Markdown("## π€ AI Models") |
|
|
model_dropdown = gr.Dropdown(["distilgpt2", "gpt2", "distilbert"], label="Select Model") |
|
|
load_model_btn = gr.Button("Load Model") |
|
|
model_info = gr.Textbox("No model loaded", label="Model Info") |
|
|
|
|
|
gr.Markdown("## π Space Creation") |
|
|
space_name = gr.Textbox("my-awesome-space", label="Space Name") |
|
|
create_space_btn = gr.Button("Create Space") |
|
|
space_status = gr.Textbox("No space created", label="Space Status") |
|
|
|
|
|
with gr.Column(): |
|
|
gr.Markdown("## π Live Development") |
|
|
metrics = gr.Textbox("CPU: 25%, Memory: 512MB", label="Live Metrics") |
|
|
refresh_btn = gr.Button("π Refresh") |
|
|
|
|
|
gr.Markdown("## π€ AI Inference") |
|
|
input_text = gr.Textbox("Enter your text here...", label="Input Text") |
|
|
inference_btn = gr.Button("π§ Run Inference") |
|
|
result = gr.Textbox("No result yet", label="Result") |
|
|
|
|
|
|
|
|
start_btn.click(fn=start_container, outputs=status) |
|
|
stop_btn.click(fn=stop_container, outputs=status) |
|
|
load_model_btn.click(fn=load_model, inputs=model_dropdown, outputs=model_info) |
|
|
create_space_btn.click(fn=lambda name: f"Space '{name}' created successfully!", inputs=space_name, outputs=space_status) |
|
|
inference_btn.click(fn=process_text, inputs=input_text, outputs=result) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch(server_name="0.0.0.0", server_port=7860) |