Skip to content

Commit a3aa00f

Browse files
authored
Merge branch 'cloudflare:production' into production
2 parents 55665e3 + e61b087 commit a3aa00f

File tree

155 files changed

+3347
-2839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+3347
-2839
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818

1919
# AI
2020

21-
/src/content/docs/ai-gateway/ @kathayl @G4brym @mchenco @pdwittig @daisyfaithauma @cloudflare/pcx-technical-writing
22-
/src/content/docs/workers-ai/ @rita3ko @pdwittig @craigsdennis @markdembo @mchenco @daisyfaithauma @cloudflare/pcx-technical-writing
21+
/src/content/docs/ai-gateway/ @kathayl @G4brym @mchenco @daisyfaithauma @cloudflare/pcx-technical-writing
22+
/src/content/docs/workers-ai/ @rita3ko @craigsdennis @markdembo @mchenco @daisyfaithauma @cloudflare/pcx-technical-writing
2323
/src/content/docs/workers-ai/static @mchenco @craigsdennis @cloudflare/pcx-technical-writing
24-
/src/content/docs/vectorize/ @elithrar @vy-ton @pdwittig @sejoker @cloudflare/pcx-technical-writing
25-
/src/content/changelogs/workers-ai.yaml @kathayl @G4brym @mchenco @pdwittig @daisyfaithauma @cloudflare/pcx-technical-writing
26-
/src/content/changelogs/ai-gateway.yaml @kathayl @G4brym @mchenco @pdwittig @daisyfaithauma @cloudflare/pcx-technical-writing
27-
/src/content/changelogs/vectorize.yaml @elithrar @pdwittig @sejoker @cloudflare/pcx-technical-writing
24+
/src/content/docs/vectorize/ @elithrar @vy-ton @sejoker @cloudflare/pcx-technical-writing
25+
/src/content/changelogs/workers-ai.yaml @kathayl @G4brym @mchenco @daisyfaithauma @cloudflare/pcx-technical-writing
26+
/src/content/changelogs/ai-gateway.yaml @kathayl @G4brym @mchenco @daisyfaithauma @cloudflare/pcx-technical-writing
27+
/src/content/changelogs/vectorize.yaml @elithrar @sejoker @cloudflare/pcx-technical-writing
2828

2929
# Analytics & Logs
3030

package-lock.json

Lines changed: 366 additions & 877 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@
2323
"@astro-community/astro-embed-youtube": "^0.5.5",
2424
"@astrojs/check": "^0.9.4",
2525
"@astrojs/react": "^3.6.2",
26-
"@astrojs/rss": "^4.0.8",
26+
"@astrojs/rss": "^4.0.9",
2727
"@astrojs/sitemap": "^3.2.1",
2828
"@astrojs/starlight": "^0.28.3",
2929
"@astrojs/starlight-docsearch": "^0.2.0",
3030
"@astrojs/starlight-tailwind": "^2.0.3",
3131
"@astrojs/tailwind": "^5.1.2",
3232
"@cloudflare/puppeteer": "^0.0.14",
33-
"@cloudflare/vitest-pool-workers": "^0.5.19",
33+
"@cloudflare/vitest-pool-workers": "^0.5.20",
3434
"@cloudflare/workers-types": "^4.20240903.0",
3535
"@codingheads/sticky-header": "^1.0.2",
3636
"@stoplight/json-schema-tree": "^4.0.0",
3737
"@types/dompurify": "^3.0.5",
3838
"@types/he": "^1.2.3",
39-
"@types/node": "^20.16.1",
39+
"@types/node": "^22.7.7",
4040
"@types/react": "^18.3.11",
4141
"@types/react-dom": "^18.3.0",
42-
"algoliasearch": "^5.8.1",
43-
"astro": "^4.16.4",
42+
"algoliasearch": "^5.9.1",
43+
"astro": "^4.16.6",
4444
"astro-breadcrumbs": "^3.2.0",
4545
"astro-icon": "^1.1.1",
4646
"astro-live-code": "^0.0.3",
47-
"date-fns": "^3.6.0",
47+
"date-fns": "^4.1.0",
4848
"detype": "1.0.12",
4949
"dompurify": "3.1.6",
5050
"dot-prop": "^9.0.0",
@@ -59,6 +59,7 @@
5959
"mermaid": "^11.3.0",
6060
"node-html-parser": "^6.1.13",
6161
"patch-package": "^8.0.0",
62+
"playwright": "^1.48.1",
6263
"prettier": "^3.3.3",
6364
"prettier-plugin-astro": "^0.14.1",
6465
"puppeteer": "^23.6.0",
@@ -68,22 +69,22 @@
6869
"redirects-in-workers": "^0.0.5",
6970
"rehype-autolink-headings": "^7.1.0",
7071
"rehype-external-links": "^3.0.0",
71-
"rehype-mermaid": "^2.1.0",
72+
"rehype-mermaid": "^3.0.0",
7273
"rehype-title-figure": "^0.1.2",
7374
"sharp": "^0.33.5",
7475
"solarflare-theme": "^0.0.2",
7576
"starlight-image-zoom": "^0.8.0",
7677
"starlight-links-validator": "^0.12.0",
7778
"starlight-package-managers": "^0.7.0",
7879
"svgo": "^3.3.2",
79-
"tailwindcss": "^3.4.10",
80+
"tailwindcss": "^3.4.14",
8081
"tippy.js": "^6.3.7",
8182
"tsx": "^4.19.1",
8283
"typescript": "^5.6.3",
8384
"unist-util-visit": "^5.0.0",
8485
"vitest": "2.1.3",
8586
"wrangler": "^3.78.10",
86-
"yaml": "^2.5.1"
87+
"yaml": "^2.6.0"
8788
},
8889
"engines": {
8990
"node": ">=22"

public/_redirects

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@
9393
/ai/ /use-cases/ai/ 301
9494

9595
# AI Gateway
96-
9796
/ai-gateway/get-started/configuring-settings/ /ai-gateway/get-started/ 301
9897
/ai-gateway/get-started/connecting-applications/ /ai-gateway/get-started/ 301
9998
/ai-gateway/get-started/creating-gateway/ /ai-gateway/get-started/ 301
10099
/ai-gateway/pricing/ /ai-gateway/reference/pricing/ 301
101100
/ai-gateway/observability/evaluations/ /ai-gateway/evaluations/ 301
102101
/ai-gateway/observability/evaluations/set-up-evaluations/ /ai-gateway/evaluations//set-up-evaluations/ 301
103-
102+
/ai-gateway/integration/vercel-ai-sdk/ /ai-gateway/integrations/vercel-ai-sdk/ 301
103+
/ai-gateway/integration/aig-workers-ai-binding/ /ai-gateway/integrations/aig-workers-ai-binding/ 301
104+
/ai-gateway/integration/ /ai-gateway/integrations/ 301
104105

105106
# analytics
106107
/analytics/migration-guides/zone-analytics/ /analytics/graphql-api/migration-guides/zone-analytics/ 301
@@ -211,7 +212,8 @@
211212
/cache/about/ /cache/concepts/ 301
212213
/cache/concepts/enable-http2-to-origin/ /speed/optimization/protocol/http2-to-origin/ 301
213214
/cache/how-to/enable-http2-to-origin/ /speed/optimization/protocol/http2-to-origin/ 301
214-
/cache/how-to/interact-with-workers/ /cache/concepts/interact-with-workers/ 301
215+
/cache/how-to/interact-with-workers/ /cache/interaction-cloudflare-products/workers/ 301
216+
/cache/concepts/interact-with-workers/ /cache/interaction-cloudflare-products/workers/ 301
215217
/cache/best-practices/cache-behavior/ /cache/concepts/cache-behavior/ 301
216218
/cache/best-practices/customize-cache/ /cache/concepts/customize-cache/ 301
217219
/cache/best-practices/ /cache/concepts/ 301
@@ -1124,6 +1126,9 @@
11241126
/support/account-management-billing/account-privacy-and-security/ /support/account-management-billing/ 301
11251127
/support/troubleshooting/general-troubleshooting/troubleshooting-surges-or-spikes-in-web-traffic/ /fundamentals/basic-tasks/preparing-for-surges-or-spikes-in-web-traffic/ 301
11261128
/support/troubleshooting/general-troubleshooting/preparing-for-surges-or-spikes-in-web-traffic/ /fundamentals/basic-tasks/preparing-for-surges-or-spikes-in-web-traffic/ 301
1129+
/support/third-party-software/others/configuring-an-amazon-web-services-static-site-to-use-cloudflare/ /rules/cloud-connector/providers/ 301
1130+
/support/third-party-software/others/enabling-cloudflare-ssl-on-azure-storage-static-web-hosting-applications/ /rules/cloud-connector/providers/ 301
1131+
11271132

11281133
# r2
11291134
/r2/platform/s3-compatibility/api/ /r2/api/s3/api/ 301
@@ -1498,6 +1503,7 @@
14981503
/workers-ai/platform/storage-options/ /workers/platform/storage-options/ 301
14991504
/workers-ai/configuration/workers-ai-sdk/ /workers-ai/configuration/bindings/ 301
15001505
/workers-ai/tutorials/creating-a-recommendation-api/ /developer-spotlight/tutorials/creating-a-recommendation-api/ 301
1506+
/workers/observability/baselime-integration/ /workers/observability/integrations/baselime-integration/ 301
15011507

15021508
# workers KV
15031509
/kv/platform/environments/ /kv/reference/environments/ 301
@@ -1655,6 +1661,7 @@
16551661
/cloudflare-one/identity/service-auth/service-tokens/ /cloudflare-one/identity/service-tokens/ 301
16561662
/cloudflare-one/identity/users/short-lived-certificates/ /cloudflare-one/connections/connect-networks/use-cases/ssh/ssh-infrastructure-access/ 301
16571663
/cloudflare-one/identity/users/validating-json/ /cloudflare-one/identity/authorization-cookie/validating-json/ 301
1664+
/cloudflare-one/policies/gateway/configuring-block-page/ /cloudflare-one/policies/gateway/block-page/ 301
16581665
/cloudflare-one/policies/lists/ /cloudflare-one/policies/gateway/lists 301
16591666
/cloudflare-one/policies/gateway/dns-policies/scheduled-dns-policies/ /cloudflare-one/policies/gateway/timed-policies/#scheduled-policies 301
16601667
/cloudflare-one/policies/zero-trust/ /cloudflare-one/policies/access/ 301
@@ -1714,6 +1721,7 @@
17141721
/cloudflare-one/tutorials/zsh-env-var/ /cloudflare-one/tutorials/cli/ 301
17151722

17161723
### DYNAMIC REDIRECTS ###
1724+
/*/sitemap.xml /sitemap-index.xml 301
17171725
/access/configuring-identity-providers/* /cloudflare-one/identity/idp-integration/:splat 301
17181726
/api-security/* /api-shield/:splat 301
17191727
/api-shield/products/* /api-shield/security/:splat 301
807 KB
Loading

src/components/Stream.astro

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
interface Props {
33
videoId: string;
44
videoTitle: string;
5-
thumbnailStartTime: string;
5+
thumbnailTimeOrURL: string;
66
}
77
8-
const { videoId, videoTitle, thumbnailStartTime } = Astro.props;
8+
const { videoId, videoTitle, thumbnailTimeOrURL } = Astro.props;
99
1010
const customerId = "1mwganm1ma0xgnmj";
1111
const baseUrl = `https://customer-${customerId}.cloudflarestream.com/`;
@@ -14,11 +14,20 @@ const url = new URL(`${videoId}/iframe`, baseUrl);
1414
url.searchParams.set("preload", "true");
1515
url.searchParams.set("letterboxColor", "transparent");
1616
17-
const thumbnailUrl = new URL(`${videoId}/thumbnails/thumbnail.jpg`, baseUrl);
18-
thumbnailUrl.searchParams.set("fit", "crop");
19-
thumbnailUrl.searchParams.set("time", thumbnailStartTime);
2017
21-
url.searchParams.set("poster", encodeURI(thumbnailUrl.toString()));
18+
// full url option
19+
if (thumbnailTimeOrURL !== undefined) {
20+
if (!thumbnailTimeOrURL.startsWith("http")) {
21+
const thumbnailUrl = new URL(`${videoId}/thumbnails/thumbnail.jpg`, baseUrl);
22+
thumbnailUrl.searchParams.set("fit", "crop");
23+
thumbnailUrl.searchParams.set("time", thumbnailTimeOrURL);
24+
25+
url.searchParams.set("poster", encodeURI(thumbnailUrl.toString()));
26+
} else {
27+
url.searchParams.set("poster", thumbnailTimeOrURL);
28+
}
29+
}
30+
2231
---
2332

2433
<div style="position: relative; padding-top: 56.25%">
@@ -28,8 +37,9 @@ url.searchParams.set("poster", encodeURI(thumbnailUrl.toString()));
2837
allow="accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture;"
2938
allowfullscreen="true"
3039
title={videoTitle}
31-
id={videoId}></iframe>
40+
id={videoId}></iframe>
3241
</div>
42+
<a href="https://www.youtube.com/@CloudflareDevelopers" target="_blank">Watch more videos on our Developer Channel</a>
3343
<script is:inline src="https://embed.cloudflarestream.com/embed/sdk.latest.js"
3444
></script>
3545
<script is:inline define:vars={{ vidId: videoId, videoTitle }}>

src/content/changelogs/ai-gateway.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ productLink: "/ai-gateway/"
55
productArea: Developer platform
66
productAreaLink: /workers/platform/changelog/platform/
77
entries:
8+
- publish_date: "2024-10-17"
9+
title: Vercel SDK
10+
description: |-
11+
Added [Vercel AI SDK](https://sdk.vercel.ai/). The SDK supports many different AI providers, tools for streaming completions, and more.
12+
813
- publish_date: "2024-09-26"
914
title: Persistent logs
1015
description: |-

src/content/changelogs/tunnel.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ productLink: "/cloudflare-one/connections/connect-networks/"
55
productArea: Cloudflare One
66
productAreaLink: /cloudflare-one/changelog/
77
entries:
8+
- publish_date: "2024-10-17"
9+
title: Simplifed WARP Connector deployment
10+
description: |-
11+
You can now deploy WARP Connector using a simplified, guided workflow similar to `cloudflared` connectors. For detailed instructions, refer to the [WARP Connector documentation](/cloudflare-one/connections/connect-networks/private-net/warp-connector/).
812
- publish_date: "2024-10-10"
913
title: Bugfix for --grace-period
1014
description: |-

src/content/changelogs/waf.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ entries:
1010
individual_page: true
1111
scheduled: true
1212
link: "/waf/change-log/scheduled-changes/"
13+
- publish_date: "2024-10-21"
14+
individual_page: true
15+
link: "/waf/change-log/2024-10-21/"
1316
- publish_date: "2024-10-14"
1417
individual_page: true
1518
link: "/waf/change-log/2024-10-14/"
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
title: Workers AI
3+
pcx_content_type: tutorial
4+
updated: 2024-10-17
5+
---
6+
7+
import { Render, PackageManagers } from "~/components";
8+
9+
This guide will walk you through setting up and deploying a Workers AI project. You will use [Workers](/workers/), an AI Gateway binding, and a large language model (LLM), to deploy your first AI-powered application on the Cloudflare global network.
10+
11+
## Prerequisites
12+
13+
<Render file="prereqs" product="workers" />
14+
15+
## 1. Create a Worker Project
16+
17+
You will create a new Worker project using the create-Cloudflare CLI (C3). C3 is a command-line tool designed to help you set up and deploy new applications to Cloudflare.
18+
19+
Create a new project named `hello-ai` by running:
20+
21+
<PackageManagers type="create" pkg="cloudflare@latest" args={"hello-ai"} />
22+
23+
Running `npm create cloudflare@latest` will prompt you to install the create-cloudflare package and lead you through setup. C3 will also install [Wrangler](/workers/wrangler/), the Cloudflare Developer Platform CLI.
24+
25+
<Render
26+
file="c3-post-run-steps"
27+
product="workers"
28+
params={{
29+
category: "hello-world",
30+
type: "Hello World Worker",
31+
lang: "TypeScript",
32+
}}
33+
/>
34+
35+
This will create a new `hello-ai` directory. Your new `hello-ai` directory will include:
36+
37+
- A "Hello World" Worker at `src/index.ts`.
38+
- A `wrangler.toml` configuration file.
39+
40+
Go to your application directory:
41+
42+
```bash
43+
cd hello-ai
44+
```
45+
46+
## 2. Connect your Worker to Workers AI
47+
48+
You must create an AI binding for your Worker to connect to Workers AI. Bindings allow your Workers to interact with resources, like Workers AI, on the Cloudflare Developer Platform.
49+
50+
To bind Workers AI to your Worker, add the following to the end of your `wrangler.toml` file:
51+
52+
```toml title="wrangler.toml"
53+
[ai]
54+
binding = "AI"
55+
```
56+
57+
Your binding is [available in your Worker code](/workers/reference/migrate-to-module-workers/#bindings-in-es-modules-format) on [`env.AI`](/workers/runtime-apis/handlers/fetch/).
58+
59+
You will need to have your `gateway id` for the next step. You can learn [how to create an AI Gateway in this tutorial](/ai-gateway/get-started/).
60+
61+
## 3. Run an inference task containing AI Gateway in your Worker
62+
63+
You are now ready to run an inference task in your Worker. In this case, you will use an LLM, [`llama-3.1-8b-instruct-fast`](/workers-ai/models/llama-3.1-8b-instruct-fast/), to answer a question. Your gateway ID is found on the dashboard.
64+
65+
Update the `index.ts` file in your `hello-ai` application directory with the following code:
66+
67+
```typescript title="src/index.ts" {78-81}
68+
export interface Env {
69+
// If you set another name in wrangler.toml as the value for 'binding',
70+
// replace "AI" with the variable name you defined.
71+
AI: Ai;
72+
}
73+
74+
export default {
75+
async fetch(request, env): Promise<Response> {
76+
// Specify the gateway label and other options here
77+
const response = await env.AI.run("@cf/meta/llama-3.1-8b-instruct-fast", {
78+
prompt: "What is the origin of the phrase Hello, World",
79+
gateway: {
80+
id: "GATEWAYID", // Use your gateway label here
81+
skipCache: true, // Optional: Skip cache if needed
82+
},
83+
});
84+
85+
// Return the AI response as a JSON object
86+
return new Response(JSON.stringify(response), {
87+
headers: { "Content-Type": "application/json" },
88+
});
89+
},
90+
} satisfies ExportedHandler<Env>;
91+
```
92+
93+
Up to this point, you have created an AI binding for your Worker and configured your Worker to be able to execute the Llama 3.1 model. You can now test your project locally before you deploy globally.
94+
95+
## 4. Develop locally with Wrangler
96+
97+
While in your project directory, test Workers AI locally by running [`wrangler dev`](/workers/wrangler/commands/#dev):
98+
99+
```bash
100+
npx wrangler dev
101+
```
102+
103+
<Render file="ai-local-usage-charges" product="workers" />
104+
105+
You will be prompted to log in after you run `wrangler dev`. When you run `npx wrangler dev`, Wrangler will give you a URL (most likely `localhost:8787`) to review your Worker. After you go to the URL Wrangler provides, you will see a message that resembles the following example:
106+
107+
````json
108+
{
109+
"response": "A fascinating question!\n\nThe phrase \"Hello, World!\" originates from a simple computer program written in the early days of programming. It is often attributed to Brian Kernighan, a Canadian computer scientist and a pioneer in the field of computer programming.\n\nIn the early 1970s, Kernighan, along with his colleague Dennis Ritchie, were working on the C programming language. They wanted to create a simple program that would output a message to the screen to demonstrate the basic structure of a program. They chose the phrase \"Hello, World!\" because it was a simple and recognizable message that would illustrate how a program could print text to the screen.\n\nThe exact code was written in the 5th edition of Kernighan and Ritchie's book \"The C Programming Language,\" published in 1988. The code, literally known as \"Hello, World!\" is as follows:\n\n```
110+
main()
111+
{
112+
printf(\"Hello, World!\");
113+
}
114+
```\n\nThis code is still often used as a starting point for learning programming languages, as it demonstrates how to output a simple message to the console.\n\nThe phrase \"Hello, World!\" has since become a catch-all phrase to indicate the start of a new program or a small test program, and is widely used in computer science and programming education.\n\nSincerely, I'm glad I could help clarify the origin of this iconic phrase for you!"
115+
}
116+
````
117+
118+
## 5. Deploy your AI Worker
119+
120+
Before deploying your AI Worker globally, log in with your Cloudflare account by running:
121+
122+
```bash
123+
npx wrangler login
124+
```
125+
126+
You will be directed to a web page asking you to log in to the Cloudflare dashboard. After you have logged in, you will be asked if Wrangler can make changes to your Cloudflare account. Scroll down and select **Allow** to continue.
127+
128+
Finally, deploy your Worker to make your project accessible on the Internet. To deploy your Worker, run:
129+
130+
```bash
131+
npx wrangler deploy
132+
```
133+
134+
Once deployed, your Worker will be available at a URL like:
135+
136+
```bash
137+
https://hello-ai.<YOUR_SUBDOMAIN>.workers.dev
138+
```
139+
140+
Your Worker will be deployed to your custom [`workers.dev`](/workers/configuration/routing/workers-dev/) subdomain. You can now visit the URL to run your AI Worker.
141+
142+
By completing this tutorial, you have created a Worker, connected it to Workers AI through an AI Gateway binding, and successfully ran an inference task using the Llama 3.1 model.

0 commit comments

Comments
 (0)