Skip to content

Commit 4f5da26

Browse files
Workers-ai-typescript (#21253)
* CLI * CLI and embedded
1 parent 5d309fb commit 4f5da26

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/content/docs/workers-ai/function-calling/embedded/get-started.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ head:
77
- tag: title
88
content: Get Started
99
---
10+
import { TypeScriptExample } from "~/components";
1011

1112
This guide will instruct you through setting up and deploying your first Workers AI project with embedded function calling. You will use Workers, a Workers AI binding, the [`ai-utils package`](https://github.com/cloudflare/ai-utils), and a large language model (LLM) to deploy your first AI-powered application on the Cloudflare global network with embedded function calling.
1213

@@ -26,7 +27,10 @@ npm install @cloudflare/ai-utils --save
2627

2728
Update the `index.ts` file in your application directory with the following code:
2829

29-
```ts title="Embedded function calling example"
30+
31+
<TypeScriptExample filename="index.ts">
32+
33+
```ts
3034
import { runWithTools } from "@cloudflare/ai-utils";
3135

3236
type Env = {
@@ -76,6 +80,7 @@ export default {
7680
},
7781
} satisfies ExportedHandler<Env>;
7882
```
83+
</TypeScriptExample>
7984

8085
This example imports the utils with `import { runWithTools} from "@cloudflare/ai-utils"` and follows the API reference below.
8186

src/content/docs/workers-ai/get-started/workers-wrangler.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ head:
99
description: Deploy your first Cloudflare Workers AI project using the CLI.
1010
---
1111

12-
import { Render, PackageManagers, WranglerConfig } from "~/components";
12+
import { Render, PackageManagers, WranglerConfig, TypeScriptExample } from "~/components";
1313

1414
This guide will instruct you through setting up and deploying your first Workers AI project. You will use [Workers](/workers/), a Workers AI binding, and a large language model (LLM) to deploy your first AI-powered application on the Cloudflare global network.
1515

@@ -73,7 +73,9 @@ You are now ready to run an inference task in your Worker. In this case, you wil
7373

7474
Update the `index.ts` file in your `hello-ai` application directory with the following code:
7575

76-
```typescript title="src/index.ts"
76+
<TypeScriptExample filename="index.ts">
77+
78+
```ts
7779
export interface Env {
7880
// If you set another name in the Wrangler config file as the value for 'binding',
7981
// replace "AI" with the variable name you defined.
@@ -90,6 +92,7 @@ export default {
9092
},
9193
} satisfies ExportedHandler<Env>;
9294
```
95+
</TypeScriptExample>
9396

9497
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.
9598

0 commit comments

Comments
 (0)