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/agents/examples/using-ai-models.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Modern [reasoning models](https://platform.openai.com/docs/guides/reasoning) or
26
26
27
27
Instead of buffering the entire response, or risking the client disconecting, you can stream the response back to the client by using the [WebSocket API](/agents/examples/websockets/).
28
28
29
-
<TypeScriptExamplefile="src/index.ts">
29
+
<TypeScriptExamplefilename="src/index.ts">
30
30
31
31
```ts
32
32
import { Agent } from"agents-sdk"
@@ -85,7 +85,7 @@ You can use [any of the models available in Workers AI](/workers-ai/models/) wit
85
85
86
86
Workers AI supports streaming responses out-of-the-box by setting `stream: true`, and we strongly recommend using them to avoid buffering and delaying responses, especially for larger models or reasoning models that require more time to generate a response.
87
87
88
-
<TypeScriptExamplefile="src/index.ts">
88
+
<TypeScriptExamplefilename="src/index.ts">
89
89
90
90
```ts
91
91
import { Agent } from"agents-sdk"
@@ -135,7 +135,7 @@ Model routing allows you to route requests to different AI models based on wheth
135
135
136
136
:::
137
137
138
-
<TypeScriptExamplefile="src/index.ts">
138
+
<TypeScriptExamplefilename="src/index.ts">
139
139
140
140
```ts
141
141
import { Agent } from"agents-sdk"
@@ -189,7 +189,7 @@ To use the AI SDK, install the `ai` package and use it within your Agent. The ex
189
189
npm install ai @ai-sdk/openai
190
190
```
191
191
192
-
<TypeScriptExamplefile="src/index.ts">
192
+
<TypeScriptExamplefilename="src/index.ts">
193
193
194
194
```ts
195
195
import { Agent } from"agents-sdk"
@@ -216,7 +216,7 @@ Agents can call models across any service, including those that support the Open
216
216
217
217
Agents can stream responses back over HTTP using Server Sent Events (SSE) from within an `onRequest` handler, or by using the native [WebSockets](/agents/examples/websockets/) API in your Agent to responses back to a client, which is especially useful for larger models that can take over 30+ seconds to reply.
Copy file name to clipboardExpand all lines: src/content/docs/style-guide/components/code.mdx
-52Lines changed: 0 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,55 +100,3 @@ export default {
100
100
};
101
101
```
102
102
````
103
-
104
-
## TypeScript examples
105
-
106
-
The `TypeScriptExample` component uses [`ts-blank-space`](https://github.com/bloomberg/ts-blank-space) to remove TypeScript-specific syntax from your example and provide a JavaScript tab. This reduces maintenance burden by only having a single example to maintain.
107
-
108
-
:::note
109
-
Some TypeScript syntax influences runtime behaviour, and cannot be stripped.
110
-
111
-
Please refer to the [Unsupported Syntax](https://github.com/bloomberg/ts-blank-space?tab=readme-ov-file#unsupported-syntax) section of the project's README.
Copy file name to clipboardExpand all lines: src/content/docs/style-guide/components/github-code.mdx
+24-3Lines changed: 24 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
title: GitHubCode
3
3
---
4
4
5
+
import { GitHubCode } from"~/components";
6
+
5
7
The `GitHubCode` component allows you to include files from Cloudflare repositories.
6
8
7
9
The remote content can be filtered by lines or a region enclosed in tags.
@@ -14,14 +16,25 @@ import { GitHubCode } from "~/components";
14
16
15
17
## Usage
16
18
17
-
```mdx live
18
-
import { GitHubCode } from"~/components";
19
+
<GitHubCode
20
+
repo="cloudflare/workflows-starter"
21
+
file="src/index.ts"
22
+
commit="a844e629ec80968118d4b116d4b26f5dcb107137"
23
+
lang="ts"
24
+
code={{
25
+
collapse: "3-6"
26
+
}}
27
+
/>
19
28
29
+
```mdx
20
30
<GitHubCode
21
31
repo="cloudflare/workflows-starter"
22
32
file="src/index.ts"
23
33
commit="a844e629ec80968118d4b116d4b26f5dcb107137"
24
34
lang="ts"
35
+
code={{
36
+
collapse: "2-3"
37
+
}}
25
38
/>
26
39
```
27
40
@@ -109,6 +122,8 @@ The long (40-characters) Git commit hash to pull from, for example `ab3951b5c953
109
122
110
123
The language to use for the code block, for example `rs`.
111
124
125
+
If the `lang` is `ts`, the [`TypeScriptExample`](/style-guide/components/typescript-example/) component will be used to provide a JavaScript tab as well.
126
+
112
127
### `lines`
113
128
114
129
**type:**`string`
@@ -121,4 +136,10 @@ A range of lines to filter the content using, for example `1-3`.
121
136
122
137
A region to filter the content with, for example `no-logging`.
123
138
124
-
This should be represented as starting `<docs-tag name="no-logging">` and closing `</docs-tag name="no-logging">` comments in the source file.
139
+
This should be represented as starting `<docs-tag name="no-logging">` and closing `</docs-tag name="no-logging">` comments in the source file.
140
+
141
+
### `code`
142
+
143
+
**type**: `object`
144
+
145
+
Props to pass to the [Expressive Code component](https://expressive-code.com/key-features/code-component/).
The `TypeScriptExample` component uses [`ts-blank-space`](https://github.com/bloomberg/ts-blank-space) to remove TypeScript-specific syntax from your example and provide a JavaScript tab. This reduces maintenance burden by only having a single example to maintain.
8
+
9
+
This component is automatically used in the [`GitHubCode`](/style-guide/components/github-code/) component when the `lang` is set to `ts`.
10
+
11
+
:::note
12
+
Some TypeScript syntax influences runtime behaviour, and cannot be stripped.
13
+
14
+
Please refer to the [Unsupported Syntax](https://github.com/bloomberg/ts-blank-space?tab=readme-ov-file#unsupported-syntax) section of the project's README.
15
+
:::
16
+
17
+
## Component
18
+
19
+
````mdx live
20
+
import { TypeScriptExample } from"~/components";
21
+
22
+
<TypeScriptExample>
23
+
```ts
24
+
interfaceEnvironment {
25
+
KV:KVNamespace;
26
+
}
27
+
28
+
exportdefault {
29
+
async fetch(req, env, ctx):Promise<Response> {
30
+
if (req!=="POST") {
31
+
returnnewResponse("Method Not Allowed", {
32
+
status: 405,
33
+
headers: {
34
+
"Allow": "POST"
35
+
}
36
+
});
37
+
}
38
+
39
+
awaitenv.KV.put("foo", "bar");
40
+
41
+
returnnewResponse();
42
+
}
43
+
} satisfiesExportedHandler<Environment>
44
+
```
45
+
</TypeScriptExample>
46
+
````
47
+
48
+
49
+
## `<TypeScriptExample>` Props
50
+
51
+
### `filename`
52
+
53
+
**type:**`string`
54
+
55
+
An optional filename, ending in `.ts`.
56
+
57
+
`.ts` will be replaced by `.js` for the JavaScript tab.
58
+
59
+
### `playground`
60
+
61
+
**type:**`boolean`
62
+
63
+
If set to `true`, a [`Run Worker in Playground`](/style-guide/components/code/#playground) button will appear on the JavaScript tab.
64
+
65
+
### `code`
66
+
67
+
**type**: `object`
68
+
69
+
Props to pass to the [Expressive Code component](https://expressive-code.com/key-features/code-component/).
70
+
71
+
These props will apply to both code blocks and so options like `collapse` may not work as expected, as lines may be removed from the TypeScript code.
Copy file name to clipboardExpand all lines: src/content/docs/workers/get-started/prompting.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1003,9 +1003,9 @@ Depending on the model and user prompt, it may generate invalid code, configurat
1003
1003
1004
1004
### Passing a system prompt
1005
1005
1006
-
If you are building an AI application that will itself generate code, you can additionally use the prompt above as a "system prompt", which will give the LLM additional information on how to structure the output code. For example:
1006
+
If you are building an AI application that will itself generate code, you can additionally use the prompt above as a "system prompt", which will give the LLM additional information on how to structure the output code. For example:
0 commit comments