Skip to content

Commit

Permalink
fix: fixes to computer use
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Nov 6, 2024
1 parent c1d136f commit 1de06c6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
6 changes: 3 additions & 3 deletions gptme/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ def prompt_gptme(interactive: bool) -> Generator[Message, None, None]:
You are designed to help users with programming tasks, such as writing code, debugging and learning new concepts.
You can run code, execute terminal commands, and access the filesystem on the local machine.
You will help the user with writing code, either from scratch or in existing projects.
You will think step by step when solving a problem, in <thinking> tags.
You will think step by step when solving a problem, in `<thinking>` tags.
Break down complex tasks into smaller, manageable steps.
You have the ability to self-correct.
If you receive feedback that your output or actions were incorrect, you should:
- acknowledge the mistake
- analyze what went wrong in <thinking> tags
- analyze what went wrong in `<thinking>` tags
- provide a corrected response
You should learn about the context needed to provide the best help,
Expand All @@ -112,7 +112,7 @@ def prompt_gptme(interactive: bool) -> Generator[Message, None, None]:
Maintain a professional and efficient communication style. Be concise but thorough in your explanations.
Think before you answer, in <thinking> tags.
Think before you answer, in `<thinking>` tags.
""".strip()

interactive_prompt = """
Expand Down
6 changes: 5 additions & 1 deletion gptme/tools/computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def computer(
run_xdotool(f"mousedown 1 mousemove --sync {x} {y} mouseup 1", display)

print(f"Moved mouse to {x},{y}")
return None
elif action in ("key", "type"):
if not text:
raise ValueError(f"text is required for {action}")
Expand All @@ -147,6 +148,7 @@ def computer(
display,
)
print(f"Typed text: {text}")
return None
elif action in ("left_click", "right_click", "middle_click", "double_click"):
click_arg = {
"left_click": "1",
Expand All @@ -156,6 +158,7 @@ def computer(
}[action]
run_xdotool(f"click {click_arg}", display)
print(f"Performed {action}")
return None
elif action == "screenshot":
# Use X11-specific screenshot if available, fall back to native
output_dir = Path(OUTPUT_DIR)
Expand All @@ -180,13 +183,14 @@ def computer(
return view_image(path)
else:
print("Error: Screenshot failed")
return None
elif action == "cursor_position":
output = run_xdotool("getmouselocation --shell", display)
x = int(output.split("X=")[1].split("\n")[0])
y = int(output.split("Y=")[1].split("\n")[0])
x, y = scale_coordinates(ScalingSource.COMPUTER, x, y, width, height)
print(f"Cursor position: X={x},Y={y}")

return None
raise ValueError(f"Invalid action: {action}")


Expand Down
16 changes: 13 additions & 3 deletions scripts/Dockerfile.computer
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@ RUN apt-get update && \
x11vnc \
tint2 \
x11-apps \
# Tools
# PPA req
software-properties-common \
# Tools \
make \
git \
tmux \
curl \
pandoc \
netcat-openbsd \
net-tools \
&& rm -rf /var/lib/apt/lists/*
net-tools

# Install Firefox
RUN sudo add-apt-repository ppa:mozillateam/ppa && \
sudo apt-get install -y --no-install-recommends firefox-esr

RUN apt-get remove -y python3-blinker

# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install noVNC for web access
RUN git clone --branch v1.5.0 https://github.com/novnc/noVNC.git /opt/noVNC && \
Expand Down
2 changes: 1 addition & 1 deletion scripts/computer_home/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
./novnc_startup.sh

# Start gptme server
python3 -m gptme.server --host 0.0.0.0 --port 8080 --tools python,computer
python3 -m gptme.server --host 0.0.0.0 --port 8080 --tools python,computer --cors-origin '*'

# Keep the container running
tail -f /dev/null

0 comments on commit 1de06c6

Please sign in to comment.