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: src/content/docs/browser-rendering/how-to/ai.mdx
+47-27Lines changed: 47 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,10 +30,15 @@ npm i zod
30
30
npm i zod-to-json-schema
31
31
```
32
32
33
-
3.Add your Browser Rendering binding to your new `wrangler.toml` configuration:
33
+
3.Activate the nodejs compatibility flag and add your Browser Rendering binding to your new `wrangler.toml` configuration:
34
34
35
35
```toml
36
-
browser = { binding = "BROWSER" }
36
+
compatibility_flags = [ "nodejs_compat" ]
37
+
```
38
+
39
+
```toml
40
+
[browser]
41
+
binding = "MY_BROWSER"
37
42
```
38
43
39
44
4. In order to use [Workers AI](/workers-ai/), you need to get your [Account ID and API token](/workers-ai/get-started/rest-api/#1-get-api-token-and-account-id).
@@ -48,13 +53,12 @@ We use `.dev.vars` here since it's only for local development, otherwise you'd u
48
53
49
54
## Load the page using Browser Rendering
50
55
51
-
In the code below, we launch a browser using `await puppeteer.launch(env.BROWSER)`, extract the rendered text and close the browser.
56
+
In the code below, we launch a browser using `await puppeteer.launch(env.MY_BROWSER)`, extract the rendered text and close the browser.
52
57
Then, with the user prompt, the desired output schema and the rendered text, prepare a prompt to send to the LLM.
53
58
54
59
Replace the contents of `src/index.ts` with the following skeleton script:
0 commit comments