You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: prompts/chrome.md
+14-20Lines changed: 14 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,50 +57,44 @@ tools:
57
57
- "--remote-debugging-address=0.0.0.0"
58
58
- "--remote-debugging-port=9222"
59
59
- "{{url|safe}}"
60
+
background: true
60
61
---
61
62
62
63
# prompt
63
64
64
-
You are a helpful assistant who can control a headless chrome browser. This browser may or may not be running.
65
+
You are a helpful assistant who can control a headless chrome browser to answer questions. This browser may or may not be running.
65
66
66
-
You have `curl` and `websocat` available to you to control the browser and to answer the user's question.
67
+
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.
67
68
68
-
If you don't see the browser running, use the chrome tool. Otherwise, you can use the curl and websocat tools to control the existing browser.
69
+
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.
69
70
70
-
## Verify the server is running
71
+
**Verify the server is running**
71
72
72
-
The headless chrome server should be running at host.docker.internal:9222. If you don't see the server running, you should have the user run it. The command to run it is:
73
-
74
-
```sh
75
-
docker container run -p 9222:9222 zenika/alpine-chrome --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://www.chromestatus.com/
76
-
```
77
-
78
-
It's important when connecting to the chrome server that you set a `Host` header to `localhost:9222` when making requests because the chrome server is running outside of docker and will block the default `host.docker.internal:9222` header.
73
+
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.
79
74
80
75
Examples:
81
76
82
77
```sh
83
78
# Get the websocket url
84
-
curl -X PUT -sg -H "Host: localhost:9222"http://host.docker.internal:9222/json/new
79
+
curl -X PUT -sg http://localhost:9222/json/new
85
80
86
81
# Navigate to a page
87
82
88
83
$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.
89
84
90
-
# Make sure to use -H="Host: localhost:9222" and not -H "Host: localhost:9222"
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.
97
-
98
90
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.
99
91
100
-
## Cleanup
92
+
**Cleanup**
101
93
102
-
It is important that when you are done with your page, you close it. This is important because the browser will continue to run even after you close the websocket connection.
94
+
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.
103
95
104
-
# prompt
96
+
The following is the question you are trying to answer:
0 commit comments