time delay for vm to process action

This commit is contained in:
Thomas Dhome-Casanova
2025-01-27 13:56:53 -08:00
parent 869323bfd9
commit 5cf55e116f

View File

@@ -234,6 +234,7 @@ class ComputerTool(BaseAnthropicTool):
json={"command": command_list}, json={"command": command_list},
timeout=90 timeout=90
) )
time.sleep(0.7) # avoid async error as actions take time to complete
print(f"action executed") print(f"action executed")
if response.status_code != 200: if response.status_code != 200:
raise ToolError(f"Failed to execute command. Status code: {response.status_code}") raise ToolError(f"Failed to execute command. Status code: {response.status_code}")
@@ -253,7 +254,7 @@ class ComputerTool(BaseAnthropicTool):
self.target_dimension = MAX_SCALING_TARGETS["WXGA"] self.target_dimension = MAX_SCALING_TARGETS["WXGA"]
width, height = self.target_dimension["width"], self.target_dimension["height"] width, height = self.target_dimension["width"], self.target_dimension["height"]
screenshot, path = get_screenshot(resize=True, target_width=width, target_height=height) screenshot, path = get_screenshot(resize=True, target_width=width, target_height=height)
time.sleep(0.7) # avoid async error as actions take time to complete
# return ToolResult() # return ToolResult()
return ToolResult(base64_image=base64.b64encode(path.read_bytes()).decode()) return ToolResult(base64_image=base64.b64encode(path.read_bytes()).decode())