Skip to content

Commit

Permalink
try fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishekbhagwat committed Oct 29, 2024
1 parent 7b2fbbc commit e838d43
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 127 deletions.
46 changes: 24 additions & 22 deletions partner-models/claude/computer-use-demo/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

# Anthropic Computer Use Demo on Google Cloud

[![Deploy in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://shell.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2FGoogleCloudPlatform%2Fgenerative-ai&cloudshell_git_branch=main&cloudshell_workspace=partner-models%2Fclaude%2Fcomputer-use-demo&cloudshell_tutorial=partner-models%2Fclaude%2Fcomputer-use-demo%2FREADME.md)

> [!CAUTION]
Expand All @@ -15,10 +17,10 @@
This repository helps you get started with computer use on Claude, with reference implementations of:

* Build files to create a Docker container with all necessary dependencies
* A computer use agent loop using the Vertex AI and GKE to access the updated Claude 3.5 Sonnet model
* Anthropic-defined computer use tools
* A streamlit app for interacting with the agent loop
- Build files to create a Docker container with all necessary dependencies
- A computer use agent loop using the Vertex AI and GKE to access the updated Claude 3.5 Sonnet model
- Anthropic-defined computer use tools
- A streamlit app for interacting with the agent loop

Please use [this form](https://forms.gle/BT1hpBrqDPDUrCqo7) to provide feedback on the quality of the model responses, the API itself, or the quality of the documentation - we cannot wait to hear from you!

Expand All @@ -34,33 +36,33 @@ We provide a simplified way to deploy this app on Google Cloud using Google Kube

1. Set up the environment variables

```bash
export PROJECT_ID=%your_project_id%
```
```bash
export PROJECT_ID=%your_project_id%
```

2. Authenticate with Google Cloud

```bash
gcloud auth application-default login
```
```bash
gcloud auth application-default login
```

3. Create a Cloud Build job to deploy the app

```bash
gcloud builds submit --config cloudbuild.yaml
```
```bash
gcloud builds submit --config cloudbuild.yaml
```

4. [Optional] Delete all created resources

```bash
gcloud builds submit --config cloudbuild-destroy.yaml
```
```bash
gcloud builds submit --config cloudbuild-destroy.yaml
```

## Local development

### Running the app locally

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

```bash
docker build . -t computer-use-demo
Expand All @@ -81,7 +83,7 @@ docker run \

Once the container is running, see the [Accessing the demo app](#accessing-the-demo-app) section below for instructions on how to connect to the interface.

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

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.

Expand All @@ -93,9 +95,9 @@ The container stores settings like the API key and custom system prompt in `~/.a

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)
- 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)

## Screen size

Expand Down Expand Up @@ -136,4 +138,4 @@ docker run \
-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.
The docker run command above mounts the repository inside the docker image, such that you can edit files from the host. Streamlit is already configured with auto reloading.
120 changes: 60 additions & 60 deletions partner-models/claude/computer-use-demo/cloudbuild-destroy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,70 @@
# limitations under the License.

steps:
- id: 'delete-k8s-resources'
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'bash'
args:
- '-c'
- |
if gcloud container clusters describe ${_CLUSTER_NAME} \
--project=${PROJECT_ID} \
--region=${_REGION} --format="none" 2>/dev/null; then
gcloud container clusters get-credentials ${_CLUSTER_NAME} \
- id: "delete-k8s-resources"
name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
entrypoint: "bash"
args:
- "-c"
- |
if gcloud container clusters describe ${_CLUSTER_NAME} \
--project=${PROJECT_ID} \
--region=${_REGION}
# Delete namespace (this will delete all resources in it)
kubectl delete namespace ${_NAMESPACE} --ignore-not-found
fi
--region=${_REGION} --format="none" 2>/dev/null; then
gcloud container clusters get-credentials ${_CLUSTER_NAME} \
--project=${PROJECT_ID} \
--region=${_REGION}
# Delete namespace (this will delete all resources in it)
kubectl delete namespace ${_NAMESPACE} --ignore-not-found
fi
- id: 'cleanup-iam'
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
waitFor: ['delete-k8s-resources']
entrypoint: 'bash'
args:
- '-c'
- |
# Remove IAM bindings
gcloud projects remove-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${_IAM_SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com" \
--role="roles/aiplatform.admin" \
--quiet || true
- id: "cleanup-iam"
name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
waitFor: ["delete-k8s-resources"]
entrypoint: "bash"
args:
- "-c"
- |
# Remove IAM bindings
gcloud projects remove-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${_IAM_SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com" \
--role="roles/aiplatform.admin" \
--quiet || true
# Delete service account
gcloud iam service-accounts delete ${_IAM_SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com \
--project=${PROJECT_ID} \
--quiet || true
# Delete service account
gcloud iam service-accounts delete ${_IAM_SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com \
--project=${PROJECT_ID} \
--quiet || true
- id: 'delete-cluster'
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
waitFor: ['cleanup-iam']
entrypoint: 'bash'
args:
- '-c'
- |
# Delete GKE cluster
echo "Deleting GKE cluster..."
gcloud container clusters delete ${_CLUSTER_NAME} \
--project=${PROJECT_ID} \
--region=${_REGION} \
--quiet || true
- id: "delete-cluster"
name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
waitFor: ["cleanup-iam"]
entrypoint: "bash"
args:
- "-c"
- |
# Delete GKE cluster
echo "Deleting GKE cluster..."
gcloud container clusters delete ${_CLUSTER_NAME} \
--project=${PROJECT_ID} \
--region=${_REGION} \
--quiet || true
- id: 'delete-registry'
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
waitFor: ['delete-cluster']
entrypoint: 'bash'
args:
- '-c'
- |
# Delete Artifact Registry repository
echo "Deleting Artifact Registry repository..."
gcloud artifacts repositories delete ${_ARTIFACT_REGISTRY_ID} \
--project=${PROJECT_ID} \
--location=${_REGION} \
--quiet || true
- id: "delete-registry"
name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
waitFor: ["delete-cluster"]
entrypoint: "bash"
args:
- "-c"
- |
# Delete Artifact Registry repository
echo "Deleting Artifact Registry repository..."
gcloud artifacts repositories delete ${_ARTIFACT_REGISTRY_ID} \
--project=${PROJECT_ID} \
--location=${_REGION} \
--quiet || true
timeout: '1800s'
timeout: "1800s"
options:
logging: CLOUD_LOGGING_ONLY
dynamicSubstitutions: true
Expand All @@ -85,5 +85,5 @@ substitutions:
_CLUSTER_NAME: computer-use-demo-cluster
_NAMESPACE: computer-use-demo
_IAM_SA_NAME: computer-use-sa
_ARTIFACT_REGISTRY_ID: computer-use-ar-repo # Added this
tags: ['gke-cleanup', '${_CLUSTER_NAME}']
_ARTIFACT_REGISTRY_ID: computer-use-ar-repo # Added this
tags: ["gke-cleanup", "${_CLUSTER_NAME}"]
Loading

0 comments on commit e838d43

Please sign in to comment.