This repository was archived by the owner on Mar 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +37
-30
lines changed
Expand file tree Collapse file tree 5 files changed +37
-30
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,15 @@ npm install workers-ai-provider
1010
1111## Usage
1212
13- First, setup an AI binding in ` wrangler.toml ` in your Workers project:
13+ First, setup an AI binding in the Wrangler config in your Workers project:
1414
15- ``` toml
16- # ...
17- [ai ]
18- binding = " AI"
19- # ...
15+ ``` jsonc
16+ {
17+ // ...
18+ " ai" : {
19+ " binding" : " AI"
20+ }
21+ }
2022```
2123
2224Then in your Worker, import the factory function and create a new AI provider:
@@ -36,7 +38,7 @@ export default {
3638 // Use the AI provider to interact with the Vercel AI SDK
3739 // Here, we generate a chat stream based on a prompt
3840 const text = await streamText ({
39- model: workersai (" @cf/meta/llama-2-7b-chat-int8 " ),
41+ model: workersai (" @cf/meta/llama-3.3-70b-instruct-fp8-fast " ),
4042 messages: [
4143 {
4244 role: " user" ,
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " workers-ai-chat" ,
3+ "main" : " src/server/index.ts" ,
4+ "compatibility_date" : " 2024-07-31" ,
5+ "assets" : {
6+ "directory" : " public"
7+ },
8+ "build" : {
9+ "command" : " esbuild src/client/index.tsx --outdir=public/dist --bundle --sourcemap --format=esm --splitting"
10+ },
11+ "ai" : {
12+ "binding" : " AI"
13+ }
14+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " workers-ai-tool-calling" ,
3+ "main" : " src/server/index.ts" ,
4+ "compatibility_date" : " 2024-07-31" ,
5+ "assets" : {
6+ "directory" : " public"
7+ },
8+ "build" : {
9+ "command" : " esbuild src/client/index.tsx --outdir=public/dist --bundle --sourcemap --format=esm --splitting"
10+ },
11+ "ai" : {
12+ "binding" : " AI"
13+ }
14+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments