File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 11/* eslint-disable */
2- // Generated by Wrangler by running `wrangler types env.d.ts --include-runtime false` (hash: f103d0d6947e92f53f1c4ba8d54acaa6 )
2+ // Generated by Wrangler by running `wrangler types env.d.ts --include-runtime false` (hash: 58d9bb5230a737a6ca0946ef9228fa8c )
33declare namespace Cloudflare {
44 interface GlobalProps {
55 mainModule : typeof import ( "./src/server" ) ;
@@ -11,6 +11,7 @@ declare namespace Cloudflare {
1111 Stateful : DurableObjectNamespace < import ( "./src/server" ) . Stateful > ;
1212 Chat : DurableObjectNamespace < import ( "./src/server" ) . Chat > ;
1313 Rpc : DurableObjectNamespace < import ( "./src/server" ) . Rpc > ;
14+ AI : Ai ;
1415 ASSETS : Fetcher ;
1516 }
1617}
Original file line number Diff line number Diff line change 1+ import { createWorkersAI } from "workers-ai-provider" ;
12import { openai } from "@ai-sdk/openai" ;
3+ import type { LanguageModelV3 } from "@ai-sdk/provider" ;
4+ import { env } from "cloudflare:workers" ;
25
3- export const model = openai ( "gpt-4o" ) ;
6+ export const model : LanguageModelV3 = ( ( ) => {
7+ if ( env . OPENAI_API_KEY ) {
8+ return openai ( "gpt-4" ) ;
9+ } else {
10+ const workersai = createWorkersAI ( { binding : env . AI } ) ;
11+ return workersai ( "@cf/meta/llama-2-7b-chat-int8" ) ;
12+ }
13+ } ) ( ) ;
Original file line number Diff line number Diff line change 77 " nodejs_compat" ,
88 " nodejs_compat_populate_process_env"
99 ],
10+ "ai" : {
11+ "binding" : " AI" ,
12+ "remote" : true
13+ },
1014 "assets" : {
1115 "binding" : " ASSETS"
1216 },
You can’t perform that action at this time.
0 commit comments