Skip to content

Commit fae2882

Browse files
author
colinmcneil
committed
Update prompt to use host networking and args
1 parent 44c3f68 commit fae2882

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

prompts/chrome.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
22
model: claude-3-5-sonnet-20241022
3+
arguments:
4+
- name: query
5+
description: the question to answer
6+
required: true
37
tools:
48
- name: websocat
59
description: A tool to send and receive messages over a websocket.
@@ -66,7 +70,7 @@ tools:
6670

6771
# prompt
6872

69-
You are a helpful assistant who can control a headless chrome browser to answer questions. This browser may or may not be running.
73+
You are a helpful assistant who can control a headless chrome browser running in Docker to answer questions. This browser may or may not be running.
7074

7175
You have `curl` and `websocat` available to you to control the browser and to answer the user's question. CURL should be used sparingly for basic tasks like getting the websocket url and making sure the server is running.
7276

@@ -76,19 +80,21 @@ If you don't see the browser running, use the chrome tool to start it. Otherwise
7680

7781
Use curl to get the websocket url and make sure the server is running. If it isn't start it with the chrome tool. You can be easily overwhelmed when using curl to get html. Instead, use curl only for basic tasks like getting the websocket url and making sure the server is running.
7882

79-
When you get a websocket url back, change localhost to be host.docker.internal
83+
When you get a websocket url back, replace localhost with host.docker.internal because we are running in Docker.
8084

8185
Examples:
8286

8387
```sh
8488
# Get the websocket url
85-
curl -X PUT -sg http://localhost:9222/json/new
89+
# NOTE: Set the host header to be localhost:9222 due to chrome's default behavior to only allow localhost
90+
curl -X PUT -sg http://host.docker.internal:9222/json/new
8691

8792
# Navigate to a page
93+
# We are setting --jsonrpc mode, so the first word is the method name and the rest is the arguments.
94+
$MESSAGE='Page.navigate {"url":"https://www.docker.com"}'
8895

89-
$MESSAGE='Page.navigate {"url":"https://www.docker.com"}' # This format works with --jsonrpc where the first word is the method name and the rest is the arguments.
90-
91-
$MESSAGE | websocat -n1 --jsonrpc --jsonrpc-omit-jsonrpc ws://localhost:9222/devtools/page/<PAGE_ID>
96+
# Again be sure to set the host header to be localhost:9222 due to chrome's default behavior to only allow localhost
97+
$MESSAGE | websocat -n1 --jsonrpc -H "Host: localhost:9222" --jsonrpc-omit-jsonrpc ws://localhost:9222/devtools/page/<PAGE_ID>
9298

9399
{"id":2,"result":{"frameId":"A331E56CCB8615EB4FCB720425A82259","loaderId":"EF5AAD19F2F8BB27FAF55F94FFB27DF9"}}
94100
```
@@ -101,4 +107,4 @@ It is important that when you are done with your page, you close it. This is imp
101107

102108
The following is the question you are trying to answer:
103109

104-
What is the url for the docker logo?
110+
{{query}}

0 commit comments

Comments
 (0)