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
Can't create a python worker that can access the AI bindings
fromjsimportResponseasyncdefon_fetch(request, env):
simple="{'prompt': 'Tell me a random quote'}"response=awaitenv.AI.run("@cf/meta/llama-2-7b-chat-int8", simple)
returnResponse.new(response)
returns
Traceback (mostrecentcalllast):
File \"/session/metadata/entry.py\", line5, inon_fetchresponse=awaitenv.AI.run(\"@cf/meta/llama-2-7b-chat-int8\", simple)
^^^^^^^^^^AttributeError: run
The text was updated successfully, but these errors were encountered:
import{Ai}from'@cloudflare/ai'
export interfaceEnv{// If you set another name in wrangler.toml as the value for 'binding',// replace "AI" with the variable name you defined.AI: any;}asyncfunctionfetch(request: Request,env: Env){constai=newAi(env.AI);constresponse=awaitai.run('@cf/meta/llama-2-7b-chat-int8',{prompt: "What is the origin of the phrase Hello, World"});}
So the run method is on the Ai wrapper and not on env.AI itself. We need some plan for how to allow Python workers to access equivalent functionality.
Can't create a python worker that can access the AI bindings
returns
The text was updated successfully, but these errors were encountered: