ai icon indicating copy to clipboard operation
ai copied to clipboard

Provider APIs (`doStream`, et al.) are not usable outside of AI SDK

Open AaronFriel opened this issue 1 year ago • 0 comments

Description

The Provider APIs doStream and doGenerate are publicly exported, but not genuinely usable without extracting functionality from the AI SDK that is not exported.

These APIs take a prompt parameter defined here:

https://github.com/vercel/ai/blob/3db90c3d44b5e4de6c7414bd6a970d166356ba94/packages/provider/src/language-model/v1/language-model-v1-prompt.ts#L1-L12

As the comment observes, "This is not a user-facing prompt." Indeed. Generating valid instances of this type from CoreMessage is performed in multiple steps using non-public functions. Here in streamText, the getValidatedPrompt and convertToLanguageModelPrompt functions are private to the core package:

https://github.com/vercel/ai/blob/3db90c3d44b5e4de6c7414bd6a970d166356ba94/packages/core/core/generate-text/stream-text.ts#L146-L159

Likewise in the definitions for generateText, generateObject, streamObject, and streamUI.

Code example

n/a

Additional context

No response

AaronFriel avatar Jul 08 '24 02:07 AaronFriel