Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
  • Loading branch information
ErikBjare and ellipsis-dev[bot] committed Oct 24, 2024
1 parent c110124 commit 09b45d5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gptme/tools/computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Similar to Anthropic's computer use demo, but integrated with gptme's architecture.
"""

import asyncio
import os
import shlex
import shutil
Expand Down Expand Up @@ -91,9 +90,7 @@ def run_xdotool(cmd: str, display: str | None = None) -> str:
"""Run an xdotool command with optional display setting."""
display_prefix = f"DISPLAY={display} " if display else ""
full_cmd = f"{display_prefix}xdotool {cmd}"
proc = subprocess.Popen(
full_cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
)
proc = subprocess.Popen(full_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
if proc.returncode != 0:
raise RuntimeError(f"xdotool command failed: {stderr.decode()}")
Expand Down Expand Up @@ -173,7 +170,9 @@ def computer_action(
x, y = scale_coordinates(
ScalingSource.COMPUTER, width, height, width, height
)
os.system(f"convert {path} -resize {x}x{y}! {path}")
subprocess.run(
f"convert {path} -resize {x}x{y}! {path}", shell=True, check=True
)
yield Message("system", f"Screenshot saved to {path}", files=[path])

elif action == "cursor_position":
Expand Down

0 comments on commit 09b45d5

Please sign in to comment.