| import gradio as gr | |
| import os | |
| import threading | |
| import time | |
| from agent.cua_agent import ComputerUsingAgent | |
| # Initialize Agent | |
| agent = ComputerUsingAgent() | |
| def execute_task(task_description): | |
| """Execute a task using the agent""" | |
| return agent.execute_task(task_description) | |
| def get_status(): | |
| """Get agent status""" | |
| return { | |
| "status": agent.task_status, | |
| "current_task": agent.current_task | |
| } | |
| # Gradio UI | |
| with gr.Blocks(title="Tiny X11 Agent") as demo: | |
| gr.Markdown("# π Tiny X11 Desktop Agent") | |
| with gr.Row(): | |
| # Desktop View | |
| gr.HTML(""" | |
| <iframe src="/vnc.html?autoconnect=true&resize=scale" | |
| width="100%" height="600" | |
| style="border: 1px solid #ccc;"></iframe> | |
| """) | |
| # Controls | |
| with gr.Column(): | |
| task_input = gr.Textbox(label="Task", placeholder="Open Firefox...") | |
| btn_run = gr.Button("Run") | |
| output = gr.JSON(label="Output") | |
| btn_run.click(execute_task, inputs=task_input, outputs=output) | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860) | |