-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add computer use demo #777
Open
kaavee315
wants to merge
9
commits into
master
Choose a base branch
from
sj/computeruseDemo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ab539e0
adding new realtime api handle function tool
sjd9021 fa89611
streamline instructions
sjd9021 9bbca42
linting checks
sjd9021 8a96b2b
adding anthroponic tools
sjd9021 6d20dd3
docker working
sjd9021 8ad8958
external tools working
sjd9021 df82ea5
google doc tools
sjd9021 b86f03b
Merge branch 'master' into sj/computeruseDemo
kaavee315 091c97e
Fix merge
kaavee315 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2024 admin | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
116 changes: 116 additions & 0 deletions
116
python/composio/tools/local/anthropicComputerTools/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
FROM docker.io/ubuntu:22.04 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV DEBIAN_PRIORITY=high | ||
|
||
RUN apt-get update && \ | ||
apt-get -y upgrade && \ | ||
apt-get -y install \ | ||
build-essential \ | ||
# UI Requirements | ||
xvfb \ | ||
xterm \ | ||
xdotool \ | ||
scrot \ | ||
imagemagick \ | ||
sudo \ | ||
mutter \ | ||
x11vnc \ | ||
# Python/pyenv reqs | ||
build-essential \ | ||
libssl-dev \ | ||
zlib1g-dev \ | ||
libbz2-dev \ | ||
libreadline-dev \ | ||
libsqlite3-dev \ | ||
curl \ | ||
git \ | ||
libncursesw5-dev \ | ||
xz-utils \ | ||
tk-dev \ | ||
libxml2-dev \ | ||
libxmlsec1-dev \ | ||
libffi-dev \ | ||
liblzma-dev \ | ||
# Network tools | ||
net-tools \ | ||
netcat \ | ||
# PPA req | ||
software-properties-common && \ | ||
# Userland apps | ||
sudo add-apt-repository ppa:mozillateam/ppa && \ | ||
sudo apt-get install -y --no-install-recommends \ | ||
libreoffice \ | ||
firefox-esr \ | ||
x11-apps \ | ||
xpdf \ | ||
gedit \ | ||
xpaint \ | ||
tint2 \ | ||
galculator \ | ||
pcmanfm \ | ||
unzip && \ | ||
apt-get clean | ||
|
||
# Install noVNC | ||
RUN git clone --branch v1.5.0 https://github.com/novnc/noVNC.git /opt/noVNC && \ | ||
git clone --branch v0.12.0 https://github.com/novnc/websockify /opt/noVNC/utils/websockify && \ | ||
ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html | ||
|
||
# setup user | ||
ENV USERNAME=computeruse | ||
ENV HOME=/home/$USERNAME | ||
RUN useradd -m -s /bin/bash -d $HOME $USERNAME | ||
RUN echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
USER computeruse | ||
WORKDIR $HOME | ||
|
||
# setup python | ||
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ | ||
cd ~/.pyenv && src/configure && make -C src && cd .. && \ | ||
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc && \ | ||
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc && \ | ||
echo 'eval "$(pyenv init -)"' >> ~/.bashrc | ||
ENV PYENV_ROOT="$HOME/.pyenv" | ||
ENV PATH="$PYENV_ROOT/bin:$PATH" | ||
ENV PYENV_VERSION_MAJOR=3 | ||
ENV PYENV_VERSION_MINOR=11 | ||
ENV PYENV_VERSION_PATCH=6 | ||
ENV PYENV_VERSION=$PYENV_VERSION_MAJOR.$PYENV_VERSION_MINOR.$PYENV_VERSION_PATCH | ||
RUN eval "$(pyenv init -)" && \ | ||
pyenv install $PYENV_VERSION && \ | ||
pyenv global $PYENV_VERSION && \ | ||
pyenv rehash | ||
|
||
ENV PATH="$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH" | ||
|
||
RUN python -m pip install --upgrade pip==23.1.2 setuptools==58.0.4 wheel==0.40.0 && \ | ||
python -m pip config set global.disable-pip-version-check true | ||
|
||
# only reinstall if requirements.txt changes | ||
COPY --chown=$USERNAME:$USERNAME requirements.txt $HOME/anthropicComputerTools/requirements.txt | ||
RUN python -m pip install -r $HOME/anthropicComputerTools/requirements.txt | ||
# Install streamlit first, explicitly | ||
RUN python -m pip install streamlit==1.38.0 | ||
|
||
# setup desktop env & app | ||
COPY --chown=$USERNAME:$USERNAME image/ $HOME | ||
COPY --chown=$USERNAME:$USERNAME . $HOME/anthropicComputerTools/ | ||
|
||
# RUN cd $HOME && \ | ||
# python -m pip install -e /home/computeruse/anthropicComputerTools | ||
# Set PYTHONPATH before using it | ||
ENV PYTHONPATH=/home/computeruse/anthropicComputerTools | ||
# Now when we modify it later, it exists | ||
ENV PYTHONPATH="${PYTHONPATH}:/home/computeruse/anthropicComputerTools" | ||
ENV COMPOSIO_PATH="/home/computeruse/anthropicComputerTools" | ||
ENV COMPOSIO_API_KEY="246jb4x8mbv1jdusbis892" | ||
|
||
ARG DISPLAY_NUM=1 | ||
ARG HEIGHT=768 | ||
ARG WIDTH=1024 | ||
ENV DISPLAY_NUM=$DISPLAY_NUM | ||
ENV HEIGHT=$HEIGHT | ||
ENV WIDTH=$WIDTH | ||
|
||
ENTRYPOINT [ "./entrypoint.sh" ] |
14 changes: 14 additions & 0 deletions
14
python/composio/tools/local/anthropicComputerTools/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2024 admin | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
8 changes: 8 additions & 0 deletions
8
...ools/local/anthropicComputerTools/image/.config/tint2/applications/firefox-custom.desktop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Desktop Entry] | ||
Name=Firefox Custom | ||
Comment=Open Firefox with custom URL | ||
Exec=firefox-esr -new-window | ||
Icon=firefox-esr | ||
Terminal=false | ||
Type=Application | ||
Categories=Network;WebBrowser; |
8 changes: 8 additions & 0 deletions
8
...omposio/tools/local/anthropicComputerTools/image/.config/tint2/applications/gedit.desktop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Desktop Entry] | ||
Name=Gedit | ||
Comment=Open gedit | ||
Exec=gedit | ||
Icon=text-editor-symbolic | ||
Terminal=false | ||
Type=Application | ||
Categories=TextEditor; |
8 changes: 8 additions & 0 deletions
8
...osio/tools/local/anthropicComputerTools/image/.config/tint2/applications/terminal.desktop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Desktop Entry] | ||
Name=Terminal | ||
Comment=Open Terminal | ||
Exec=xterm | ||
Icon=utilities-terminal | ||
Terminal=false | ||
Type=Application | ||
Categories=System;TerminalEmulator; |
100 changes: 100 additions & 0 deletions
100
python/composio/tools/local/anthropicComputerTools/image/.config/tint2/tint2rc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#------------------------------------- | ||
# Panel | ||
panel_items = TL | ||
panel_size = 100% 60 | ||
panel_margin = 0 0 | ||
panel_padding = 2 0 2 | ||
panel_background_id = 1 | ||
wm_menu = 0 | ||
panel_dock = 0 | ||
panel_position = bottom center horizontal | ||
panel_layer = top | ||
panel_monitor = all | ||
panel_shrink = 0 | ||
autohide = 0 | ||
autohide_show_timeout = 0 | ||
autohide_hide_timeout = 0.5 | ||
autohide_height = 2 | ||
strut_policy = follow_size | ||
panel_window_name = tint2 | ||
disable_transparency = 1 | ||
mouse_effects = 1 | ||
font_shadow = 0 | ||
mouse_hover_icon_asb = 100 0 10 | ||
mouse_pressed_icon_asb = 100 0 0 | ||
scale_relative_to_dpi = 0 | ||
scale_relative_to_screen_height = 0 | ||
|
||
#------------------------------------- | ||
# Taskbar | ||
taskbar_mode = single_desktop | ||
taskbar_hide_if_empty = 0 | ||
taskbar_padding = 0 0 2 | ||
taskbar_background_id = 0 | ||
taskbar_active_background_id = 0 | ||
taskbar_name = 1 | ||
taskbar_hide_inactive_tasks = 0 | ||
taskbar_hide_different_monitor = 0 | ||
taskbar_hide_different_desktop = 0 | ||
taskbar_always_show_all_desktop_tasks = 0 | ||
taskbar_name_padding = 4 2 | ||
taskbar_name_background_id = 0 | ||
taskbar_name_active_background_id = 0 | ||
taskbar_name_font_color = #e3e3e3 100 | ||
taskbar_name_active_font_color = #ffffff 100 | ||
taskbar_distribute_size = 0 | ||
taskbar_sort_order = none | ||
task_align = left | ||
|
||
#------------------------------------- | ||
# Launcher | ||
launcher_padding = 4 8 4 | ||
launcher_background_id = 0 | ||
launcher_icon_background_id = 0 | ||
launcher_icon_size = 48 | ||
launcher_icon_asb = 100 0 0 | ||
launcher_icon_theme_override = 0 | ||
startup_notifications = 1 | ||
launcher_tooltip = 1 | ||
|
||
#------------------------------------- | ||
# Launcher icon | ||
launcher_item_app = /usr/share/applications/libreoffice-calc.desktop | ||
launcher_item_app = /home/computeruse/.config/tint2/applications/terminal.desktop | ||
launcher_item_app = /home/computeruse/.config/tint2/applications/firefox-custom.desktop | ||
launcher_item_app = /usr/share/applications/xpaint.desktop | ||
launcher_item_app = /usr/share/applications/xpdf.desktop | ||
launcher_item_app = /home/computeruse/.config/tint2/applications/gedit.desktop | ||
launcher_item_app = /usr/share/applications/galculator.desktop | ||
|
||
#------------------------------------- | ||
# Background definitions | ||
# ID 1 | ||
rounded = 0 | ||
border_width = 0 | ||
background_color = #000000 60 | ||
border_color = #000000 30 | ||
|
||
# ID 2 | ||
rounded = 4 | ||
border_width = 1 | ||
background_color = #777777 20 | ||
border_color = #777777 30 | ||
|
||
# ID 3 | ||
rounded = 4 | ||
border_width = 1 | ||
background_color = #777777 20 | ||
border_color = #ffffff 40 | ||
|
||
# ID 4 | ||
rounded = 4 | ||
border_width = 1 | ||
background_color = #aa4400 100 | ||
border_color = #aa7733 100 | ||
|
||
# ID 5 | ||
rounded = 4 | ||
border_width = 1 | ||
background_color = #aaaa00 100 | ||
border_color = #aaaa00 100 |
6 changes: 6 additions & 0 deletions
6
python/composio/tools/local/anthropicComputerTools/image/.streamlit/config.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[server] | ||
fileWatcherType = "auto" | ||
runOnSave = true | ||
|
||
[browser] | ||
gatherUsageStats = false |
15 changes: 15 additions & 0 deletions
15
python/composio/tools/local/anthropicComputerTools/image/entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
./start_all.sh | ||
./novnc_startup.sh | ||
|
||
python http_server.py > /tmp/server_logs.txt 2>&1 & | ||
cd $HOME/anthropicComputerTools | ||
STREAMLIT_SERVER_PORT=8501 python -m streamlit run streamlit_project.py > /tmp/streamlit_stdout.log & | ||
|
||
echo "✨ Computer Use Demo is ready!" | ||
echo "➡️ Open http://localhost:8080 in your browser to begin" | ||
|
||
# Keep the container running | ||
tail -f /dev/null |
19 changes: 19 additions & 0 deletions
19
python/composio/tools/local/anthropicComputerTools/image/http_server.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
import socket | ||
from http.server import HTTPServer, SimpleHTTPRequestHandler | ||
|
||
|
||
class HTTPServerV6(HTTPServer): | ||
address_family = socket.AF_INET6 | ||
|
||
|
||
def run_server(): | ||
os.chdir(os.path.dirname(__file__) + "/static_content") | ||
server_address = ("::", 8080) | ||
httpd = HTTPServerV6(server_address, SimpleHTTPRequestHandler) | ||
print("Starting HTTP server on port 8080...") # noqa: T201 | ||
httpd.serve_forever() | ||
|
||
|
||
if __name__ == "__main__": | ||
run_server() |
43 changes: 43 additions & 0 deletions
43
python/composio/tools/local/anthropicComputerTools/image/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Computer Use Demo</title> | ||
<meta name="permissions-policy" content="fullscreen=*" /> | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
overflow: hidden; | ||
} | ||
.container { | ||
display: flex; | ||
height: 100vh; | ||
width: 100vw; | ||
} | ||
.left { | ||
flex: 1; | ||
border: none; | ||
height: 100vh; | ||
} | ||
.right { | ||
flex: 2; | ||
border: none; | ||
height: 100vh; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<iframe | ||
src="http://localhost:8501" | ||
class="left" | ||
allow="fullscreen" | ||
></iframe> | ||
<iframe | ||
src="http://localhost:6080/vnc.html?view_only=1&autoconnect=1&resize=scale" | ||
class="right" | ||
allow="fullscreen" | ||
></iframe> | ||
</div> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
python/composio/tools/local/anthropicComputerTools/image/mutter_startup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
echo "starting mutter" | ||
XDG_SESSION_TYPE=x11 mutter --replace --sm-disable 2>/tmp/mutter_stderr.log & | ||
|
||
# Wait for tint2 window properties to appear | ||
timeout=30 | ||
while [ $timeout -gt 0 ]; do | ||
if xdotool search --class "mutter" >/dev/null 2>&1; then | ||
break | ||
fi | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
if [ $timeout -eq 0 ]; then | ||
echo "mutter stderr output:" >&2 | ||
cat /tmp/mutter_stderr.log >&2 | ||
exit 1 | ||
fi | ||
|
||
rm /tmp/mutter_stderr.log |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoding API keys in the Dockerfile is a security risk. Consider using environment variables or a secrets management tool to handle sensitive information.