File size: 1,643 Bytes
3508f42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from controller import Controller
import time
import os

def process_command(command):
    """处理用户输入的命令"""
    controller = Controller()
    success, message = controller.execute_command(command)
    return message

# 创建 Gradio 界面
def create_interface():
    with gr.Blocks(title="Mac Vision Control Agent") as interface:
        gr.Markdown("""
        # Mac Vision Control Agent
        
        使用自然语言控制您的 Mac。输入您想要执行的操作,系统将自动分析屏幕并执行相应操作。
        
        示例命令:
        - "打开 Safari 并访问 google.com"
        - "在 Finder 中打开下载文件夹"
        - "打开系统偏好设置中的显示器选项"
        """)
        
        with gr.Row():
            command_input = gr.Textbox(
                label="输入命令",
                placeholder="请输入自然语言命令...",
                lines=2
            )
        
        with gr.Row():
            submit_btn = gr.Button("执行")
        
        output = gr.Textbox(label="执行结果")
        
        submit_btn.click(
            fn=process_command,
            inputs=command_input,
            outputs=output
        )
    
    return interface

if __name__ == "__main__":
    interface = create_interface()
    interface.queue()  # 添加队列支持
    interface.launch(
        server_name="0.0.0.0",  # 改回 0.0.0.0
        server_port=7861,
        share=True,
        auth=None,
        inbrowser=True,
        show_error=True,  # 显示详细错误信息
        quiet=False  # 显示更多日志
    )