-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathsandbox_agent.py
34 lines (25 loc) · 1.05 KB
/
sandbox_agent.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
from os_computer_use.sandbox_agent import SandboxAgent
# This is a mock sandbox that returns a static screenshot and terminal output
class MockSandbox:
def __init__(self):
self.timeout = 60
self.commands = self
def screenshot(self):
with open("./tests/test_screenshot.png", "rb") as f:
return f.read()
def run(self, command, timeout=None, background=False):
class MockResult:
def __init__(self):
self.stdout = f"Mock stdout for command: {command}"
self.stderr = ""
return MockResult()
def set_timeout(self, timeout):
self.timeout = timeout
if __name__ == "__main__":
# Create an instance of SandboxAgent with the mock sandbox
agent = SandboxAgent(MockSandbox(), save_logs=False)
# Test the agent with a sample instruction
# This will verify that the model providers are working correctly.
test_instruction = "Open the Firefox browser"
print("\nRunning test with instruction:", test_instruction)
agent.run(test_instruction)