Skip to content

Commit 6ba69df

Browse files
author
colinmcneil
committed
Tool-only chrome prompt
1 parent ec02c15 commit 6ba69df

File tree

1 file changed

+9
-44
lines changed

1 file changed

+9
-44
lines changed

prompts/chrome.md

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ arguments:
88
parameter-values:
99
query: "Show me the most viral yt thumbnail from the last 2 weeks."
1010
tools:
11-
- name: websocat
12-
description: A tool to send and receive messages over a websocket.
11+
- name: interact-with-chrome
12+
description: A tool to send and receive messages to headless chrome via a websocket. Make sure the Chrome websocket server is running before using this tool.
1313
parameters:
1414
type: object
1515
properties:
1616
endpoint:
1717
type: string
18-
description: The url of the websocket endpoint.
18+
description: "The url of the websocket endpoint Chrome is listening on. REPLACE LOCALHOST WITH HOST.DOCKER.INTERNAL. Example: `ws://host.docker.internal:9222/devtools/page/<PAGE_ID>`"
1919
message:
2020
type: string
21-
description: The message to send to websocat on stdin.
21+
description: "The message to send to the Chrome websocket. Example: `{\"id\":2,\"method\":\"Page.navigate\",\"params\":{\"url\":\"https://www.youtube.com\"}}`"
2222
required:
2323
- endpoint
2424
- message
@@ -31,19 +31,19 @@ tools:
3131
- "-H=Host: localhost:9222"
3232
- '{{endpoint|safe}}'
3333
- name: curl
34-
description: Run a curl command.
34+
description: Run a curl command to get the websocket url and make sure that Chrome's websocket server is running. ALWAYS USE THIS TOOL FIRST. MAKE SURE TO USE THE CORRECT HOST HEADER AND ENDPOINT.
3535
parameters:
3636
type: object
3737
properties:
3838
args:
3939
type: string
40-
description: The arguments to pass to curl
40+
description: "The arguments to pass to curl. Make sure to use the correct host header (localhost) and endpoint (9222). Example: `-X PUT -H \"Host: localhost:9222\" -sg http://host.docker.internal:9222/json/new`"
4141
container:
4242
image: vonwig/curl:latest
43-
command:
43+
command:
4444
- "{{raw|safe}}"
45-
- name: chrome
46-
description: Starts the chrome browser.
45+
- name: start-chrome
46+
description: Starts the chrome browser in case it is not already running.
4747
parameters:
4848
type: object
4949
properties:
@@ -68,41 +68,6 @@ tools:
6868

6969
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.
7070

71-
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.
72-
73-
If you don't see the browser running, use the chrome tool to start it. Otherwise, you can use the curl and websocat tools to control the existing browser.
74-
75-
## Verify the server is running
76-
77-
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.
78-
79-
When you get a websocket url back, replace localhost with host.docker.internal because we are running in Docker.
80-
81-
Examples:
82-
83-
```sh
84-
# Get the websocket url
85-
# NOTE: Set the host header to be localhost:9222 due to chrome's default behavior to only allow localhost
86-
curl -X PUT -H "Host: localhost:9222" -sg http://host.docker.internal:9222/json/new
87-
88-
# Navigate to a page
89-
$MESSAGE='{...}'
90-
91-
$MESSAGE | websocat ws://host.docker.internal:9222/devtools/page/<PAGE_ID>
92-
93-
{"id":2,"result":{"frameId":"A331E56CCB8615EB4FCB720425A82259","loaderId":"EF5AAD19F2F8BB27FAF55F94FFB27DF9"}}
94-
```
95-
96-
For more complex tasks, use websocat to send and receive messages to the browser. This can be used to execute javascript, navigate to a page, or screenshot the page.
97-
98-
## Answering the Question
99-
100-
Your goal is to control the Chrome instance to answer the user's question. You can also use curl to save things to the `/thread/` folder. Anything in the `/thread` folder will be memoized for you. This is particularly useful for saving screenshots.
101-
102-
## Cleanup
103-
104-
It is important that when you are done with your page, you close it. This is important because the browser could continue to run even after you close the websocket connection.
105-
10671
## Question
10772

10873
The following is the question you are trying to answer:

0 commit comments

Comments
 (0)