-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
55 lines (44 loc) · 1.48 KB
/
main.py
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
from os_computer_use.streaming import Sandbox, DisplayClient
from os_computer_use.sandbox_agent import SandboxAgent
from os_computer_use.llm import qwen
import asyncio
async def start():
sandbox = None
client = None
try:
sandbox = Sandbox()
client = DisplayClient()
print("Starting the display server...")
stream_url = sandbox.start_stream()
await asyncio.sleep(2.5)
print("Starting the display client...")
await client.start_display_client(stream_url)
agent = SandboxAgent(qwen, sandbox)
while True:
try:
user_input = input("USER: ")
agent.run(user_input)
except KeyboardInterrupt:
print("\nExit key pressed.")
break
finally:
if client:
print("Stopping the display client...")
try:
await client.stop_display_client()
except Exception as e:
print(f"Error stopping display client: {str(e)}")
if sandbox:
print("Stopping the sandbox...")
try:
sandbox.kill()
except Exception as e:
print(f"Error stopping sandbox: {str(e)}")
if client:
print("Saving the stream as mp4...")
try:
await client.save_stream()
except Exception as e:
print(f"Error saving stream: {str(e)}")
def main():
asyncio.run(start())