Skip to content

AI: Typescript code samples for hermes-2-pro-mistral-7b lead to type errors in my local environment #15930

@brettimus

Description

@brettimus

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:

image image

The problem appears to be that I need to coerce the inputs to: BaseAiTextGeneration["inputs"], which makes type inference work again

image

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.

Metadata

Metadata

Labels

content:editRequest for content editsdocumentationDocumentation editsproduct:workers-aiWorkers AI: https://developers.cloudflare.com/workers-ai/

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions