Skip to content
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 precommit #37

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
files: ^computer-use-demo/
default_stages: [pre-commit, pre-push]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.7
hooks:
- id: ruff
name: Run `ruff` to autofix lint errors
args: [--fix-only]
- id: ruff
name: Run `ruff` to format code
entry: ruff format --force-exclude
- id: ruff
name: Run `ruff` to lint code
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.384
hooks:
- id: pyright
6 changes: 6 additions & 0 deletions computer-use-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Once the container is running, open your browser to [http://localhost:8080](http
The container stores settings like API key and custom system prompt in `~/.anthropic/`. Mount this directory to persist these settings between container runs.

Alternative access points:

- Streamlit interface only: [http://localhost:8501](http://localhost:8501)
- Desktop view only: [http://localhost:6080/vnc.html](http://localhost:6080/vnc.html)
- Direct VNC connection: `vnc://localhost:5900` (for VNC clients)
Expand Down Expand Up @@ -94,6 +95,7 @@ docker run \
```

### Vertex

You'll need to pass in Google Cloud credentials with appropriate permissions to use Claude on Vertex.

```bash
Expand All @@ -112,11 +114,13 @@ docker run \
-p 8080:8080 \
-it computer-use-demo
```

This example shows how to use the Google Cloud Application Default Credentials to authenticate with Vertex.

You can also set `GOOGLE_APPLICATION_CREDENTIALS` to use an arbitrary credential file, see the [Google Cloud Authentication documentation](https://cloud.google.com/docs/authentication/application-default-credentials#GAC) for more details.

## Screen size

Environment variables `WIDTH` and `HEIGHT` can be used to set the screen size. For example:

```bash
Expand All @@ -137,6 +141,7 @@ We do not recommend sending screenshots in resolutions above [XGA/WXGA](https://
Relying on the image resizing behavior in the API will result in lower model accuracy and slower performance than implementing scaling in your tools directly. The `computer` tool implementation in this project demonstrates how to scale both images and coordinates from higher resolutions to the suggested resolutions.

## Development

```bash
./setup.sh # configure venv, install development dependencies, and install pre-commit hooks
docker build . -t computer-use-demo:local # manually build the docker image (optional)
Expand All @@ -151,4 +156,5 @@ docker run \
-p 8080:8080 \
-it computer-use-demo:local # can also use ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest
```

The docker run command above mounts the repo inside the docker image, such that you can edit files from the host. Streamlit is already configured with auto reloading.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.pyright]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm is this meant to be in the root folder?

venvPath = "computer-use-demo"
venv = ".venv"
useLibraryCodeForTypes = false
Loading