-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Existing documentation URL(s)
Code Examples > Worker on this page:
Traditional function calling section on this page:
What changes are you suggesting?
The issue appears to be downstream, having to do with type inference on the Ai.run method, however, I would expect the code from the documentation to not give type errors when I copy paste it into my editor:
The problem appears to be that I need to coerce the inputs to: BaseAiTextGeneration["inputs"], which makes type inference work again
Additional information
I created a minimal example by running npm create cloudflare@latest, which used @2.23.0. I created a Hello World worker, selected Typescript, installed deps.
I enabled AI bindings, and then copy-pasted the code samples from the pages linked above to test.
Code is here
I need to investigate a bit more, but there seem to be several problems with the workers types for AI. (Where should I file an issue about that?) Type inference on Ai.run does not work as expected, and then certain types that describe inputs for the AI models have actually caused errors when I conform to them. But that's a different thing I guess.