Skip to content

Commit c74715f

Browse files
Merge branch 'cloudflare:production' into production
2 parents 16e61ca + 5f3ed73 commit c74715f

File tree

71 files changed

+772
-351
lines changed

Some content is hidden

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

71 files changed

+772
-351
lines changed
220 KB
Loading

src/components/Stream.astro

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,37 @@ if (thumbnailTimeOrURL !== undefined) {
7171
const title = this.dataset.title as string;
7272

7373
const player = this.querySelector(`#${id}`) as HTMLIFrameElement;
74+
const stream = Stream(player);
7475

75-
Stream(player).addEventListener("play", () => {
76-
track("play docs video", { title: title });
76+
stream.addEventListener("play", () => {
77+
track("play docs video", { title });
78+
});
79+
80+
stream.addEventListener("pause", () => {
81+
track("paused docs video", {
82+
title,
83+
time: stream.currentTime.toFixed(1),
84+
});
85+
});
86+
87+
stream.addEventListener("seeked", () => {
88+
track("seeked docs video", {
89+
title,
90+
time: stream.currentTime.toFixed(1),
91+
});
92+
});
93+
94+
stream.addEventListener("ended", () => {
95+
track("ended docs video", { title });
96+
});
97+
98+
stream.addEventListener("ratechange", () => {
99+
if (stream.playbackRate === 0 || stream.playbackRate === 1) return;
100+
101+
track("changed playback rate docs video", {
102+
title,
103+
rate: stream.playbackRate,
104+
});
77105
});
78106
}
79107
}

src/components/overrides/Sidebar.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Default from "@astrojs/starlight/components/Sidebar.astro";
55
import { Icon as AstroIcon } from "astro-icon/components";
66
import { lookupProductTitle } from "~/util/sidebar";
77
8-
const [product, module] = Astro.url.pathname.split("/").slice(1, -1);
8+
const [product, module] = Astro.url.pathname.split("/").filter(Boolean);
99
---
1010

1111
<a

src/components/overrides/TableOfContents.astro

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,35 @@
22
import type { Props } from "@astrojs/starlight/props";
33
import Default from "@astrojs/starlight/components/TableOfContents.astro";
44
5+
import { Icon } from "@astrojs/starlight/components";
56
import FeedbackPrompt from "../FeedbackPrompt.tsx";
67
---
78

89
<Default {...Astro.props} />
10+
{
11+
!Astro.url.pathname.startsWith("/support/") && (
12+
<>
13+
<br />
14+
<div class="flex gap-2">
15+
{Astro.props.editUrl && (
16+
<a
17+
href={Astro.props.editUrl}
18+
class="h-8 cursor-pointer content-center rounded bg-cl1-brand-orange px-4 text-sm font-medium text-cl1-black"
19+
>
20+
<Icon name="pencil" />
21+
Edit
22+
</a>
23+
)}
24+
<a
25+
href="https://github.com/cloudflare/cloudflare-docs/issues/new/choose"
26+
class="h-8 cursor-pointer content-center rounded bg-cl1-brand-orange px-4 text-sm font-medium text-cl1-black"
27+
>
28+
<Icon name="github" />
29+
Issue
30+
</a>
31+
</div>
32+
</>
33+
)
34+
}
935
<br />
1036
<FeedbackPrompt client:idle />
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Introducing Guardrails in AI Gateway
3+
description: Keep AI interactions secure and risk-free with Guardrails in AI Gateway
4+
products:
5+
- ai-gateway
6+
date: 2025-02-26T6:00:00Z
7+
---
8+
9+
[AI Gateway](/ai-gateway/) now includes [Guardrails](/ai-gateway/guardrails/), to help you monitor your AI apps for harmful or inappropriate content and deploy safely.
10+
11+
Within the AI Gateway settings, you can configure:
12+
- **Guardrails**: Enable or disable content moderation as needed.
13+
- **Evaluation scope**: Select whether to moderate user prompts, model responses, or both.
14+
- **Hazard categories**: Specify which categories to monitor and determine whether detected inappropriate content should be blocked or flagged.
15+
16+
![Guardrails in AI Gateway](~/assets/images/ai-gateway/Guardrails.png)
17+
18+
Learn more in the [blog](https://blog.cloudflare.com/guardrails-in-ai-gateway/) or our [documentation](/ai-gateway/guardrails/).
Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,70 @@
11
---
2-
title: Workers AI JSON Mode
2+
title: Workers AI now supports structured JSON outputs.
33
description: Workers AI JSON Mode adds structured outputs support
44
date: 2025-02-25T15:00:00Z
55
---
66

7-
We've updated the Workers AI to support [JSON mode](/workers-ai/json-mode/), enabling applications to request a structured output response when interacting with AI models.
7+
import { TypeScriptExample } from "~/components";
8+
9+
Workers AI now supports structured JSON outputs with [JSON mode](/workers-ai/json-mode/), which allows you to request a structured output response when interacting with AI models.
10+
11+
This makes it much easier to retrieve structured data from your AI models, and avoids the (error prone!) need to parse large unstructured text responses to extract your data.
12+
13+
JSON mode in Workers AI is compatible with the OpenAI SDK's [structured outputs](https://platform.openai.com/docs/guides/structured-outputs) `response_format` API, which can be used directly in a Worker:
14+
15+
<TypeScriptExample>
16+
17+
```ts
18+
import { OpenAI } from "openai";
19+
20+
interface Env {
21+
OPENAI_API_KEY: string;
22+
}
23+
24+
// Define your JSON schema for a calendar event
25+
const CalendarEventSchema = {
26+
type: 'object',
27+
properties: {
28+
name: { type: 'string' },
29+
date: { type: 'string' },
30+
participants: { type: 'array', items: { type: 'string' } },
31+
},
32+
required: ['name', 'date', 'participants']
33+
};
34+
35+
export default {
36+
async fetch(request: Request, env: Env) {
37+
const client = new OpenAI({
38+
apiKey: env.OPENAI_API_KEY,
39+
// Optional: use AI Gateway to bring logs, evals & caching to your AI requests
40+
// https://developers.cloudflare.com/ai-gateway/providers/openai/
41+
// baseUrl: "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai"
42+
});
43+
44+
const response = await client.chat.completions.create({
45+
model: 'gpt-4o-2024-08-06',
46+
messages: [
47+
{ role: 'system', content: 'Extract the event information.' },
48+
{ role: 'user', content: 'Alice and Bob are going to a science fair on Friday.' },
49+
],
50+
// Use the `response_format` option to request a structured JSON output
51+
response_format: {
52+
// Set json_schema and provide ra schema, or json_object and parse it yourself
53+
type: 'json_schema',
54+
schema: CalendarEventSchema, // provide a schema
55+
},
56+
});
57+
58+
// This will be of type CalendarEventSchema
59+
const event = response.choices[0].message.parsed;
60+
61+
return Response.json({
62+
"calendar_event": event,
63+
})
64+
}
65+
}
66+
```
67+
68+
</TypeScriptExample>
69+
70+
To learn more about JSON mode and structured outputs, visit the [Workers AI documentation](/workers-ai/json-mode/).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Concurrent Workflow instances limits increased.
3+
description: Increased concurrency limits for Workflows instances
4+
- workflows
5+
date: 2025-02-25T15:00:00Z
6+
---
7+
8+
import { Render, PackageManagers, TypeScriptExample } from "~/components"
9+
10+
[Workflows](/workflows/) now supports up to 4,500 concurrent (running) instances, up from the previous limit of 100. This limit will continue to increase during the Workflows open beta. This increase applies to all users on the Workers Paid plan, and takes effect immediately.
11+
12+
Review the Workflows [limits documentation](/workflows/reference/limits) and/or dive into the [get started guide](/workflows/get-started/guide/) to start building on Workflows.

src/content/docs/agents/platform/limits.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Limits that apply to authoring, deploying, and running Agents are detailed below
1212

1313
Many limits are inherited from those applied to Workers scripts and/or Durable Objects, and are detailed in the [Workers limits](/workers/platform/limits/) documentation.
1414

15-
::: note
16-
1715
| Feature | Limit |
1816
| ----------------------------------------- | ----------------------- |
1917
| Max concurrent (running) Agents per account | Tens of millions+ [^1]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Guardrails
3+
pcx_content_type: navigation
4+
order: 1
5+
sidebar:
6+
order: 8
7+
group:
8+
badge: Beta
9+
---
10+
11+
import { CardGrid, LinkTitleCard } from "~/components";
12+
13+
Guardrails help you deploy AI applications safely by intercepting and evaluating both user prompts and model responses for harmful content. Acting as a proxy between your application and [model providers](/ai-gateway/providers/) (such as OpenAI, Anthropic, DeepSeek, and others), AI Gateway's Guardrails ensure a consistent and secure experience across your entire AI ecosystem.
14+
15+
Guardrails proactively monitor interactions between users and AI models, giving you:
16+
17+
- **Consistent moderation**: Uniform moderation layer that works across models and providers.
18+
- **Enhanced safety and user trust**: Proactively protect users from harmful or inappropriate interactions.
19+
- **Flexibility and control over allowed content**: Specify which categories to monitor and choose between flagging or outright blocking.
20+
- **Auditing and compliance capabilities**: Receive updates on evolving regulatory requirements with logs of user prompts, model responses, and enforced guardrails.
21+
22+
## How Guardrails work
23+
24+
AI Gateway inspects all interactions in real time by evaluating content against predefined safety parameters. Guardrails work by:
25+
26+
1. Intercepting interactions:
27+
AI Gateway proxies requests and responses, sitting between the user and the AI model.
28+
29+
2. Inspecting content:
30+
31+
- User prompts: AI Gateway checks prompts against safety parameters (for example, violence, hate, or sexual content). Based on your settings, prompts can be flagged or blocked before reaching the model.
32+
- Model responses: Once processed, the AI model response is inspected. If hazardous content is detected, it can be flagged or blocked before being delivered to the user.
33+
34+
3. Applying actions:
35+
Depending on your configuration, flagged content is logged for review, while blocked content is prevented from proceeding.
36+
37+
## Related resource
38+
- [Cloudflare Blog: Keep AI interactions secure and risk-free with Guardrails in AI Gateway](https://blog.cloudflare.com/guardrails-in-ai-gateway/)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
pcx_content_type: how-to
3+
title: Set up Guardrails
4+
sidebar:
5+
order: 3
6+
---
7+
8+
Add Guardrails to any gateway to start evaluating and potentially modifying responses.
9+
10+
1. Log into the [Cloudflare dashboard](https://dash.cloudflare.com/) and select your account.
11+
2. Go to **AI** > **AI Gateway**.
12+
3. Select a gateway.
13+
4. Go to **Guardrails**.
14+
5. Switch the toggle to **On**.
15+
6. To customize categories, select **Change** > **Configure specific categories**.
16+
7. Update your choices for how Guardrails works on specific prompts or responses (**Flag**, **Ignore**, **Block**).
17+
- For **Prompts**: Guardrails will evaluate and transform incoming prompts based on your security policies.
18+
- For **Responses**: Guardrails will inspect the model's responses to ensure they meet your content and formatting guidelines.
19+
8. Select **Save**.
20+
21+
:::note[Usage considerations]
22+
For additional details about how to implement Guardrails, refer to [Usage considerations](/ai-gateway/guardrails/usage-considerations/).
23+
:::

0 commit comments

Comments
 (0)