fix(aisdk): request non-streaming response in doGenerate (#470)#515
Open
serhiizghama wants to merge 2 commits into
Open
fix(aisdk): request non-streaming response in doGenerate (#470)#515serhiizghama wants to merge 2 commits into
serhiizghama wants to merge 2 commits into
Conversation
The Vercel AI SDK provider was calling ai.chat(req) without options,
relying on the default behavior. AxBaseAI defaults stream to true when
omitted, causing chat() to return a ReadableStream cast as
AxChatResponse, so accessing res.results.at(0) threw
"Cannot read properties of undefined (reading 'at')" when used through
generateText/streamText with non-streaming entrypoints.
Pass { stream: false } explicitly so doGenerate always receives an
AxChatResponse and the existing cast holds.
Add an assertion that doGenerate forwards stream: false to ai.chat, and update the existing prompt-conversion test to match the new second argument.
|
does this make the integration work with V6 as well? |
Collaborator
|
can you fix the merge conflict so i can merge this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using the
@ax-llm/ax-ai-sdk-providerwithgenerateText(or any non-streaming Vercel AI SDK entrypoint), the call crashes with:AxAIProvider.doGeneratewas callingthis.ai.chat(req)without the secondoptionsargument.AxBaseAI.chatdefaultsstreamtotruewhen no value is supplied, so the call returned aReadableStream<AxChatResponse>cast asAxChatResponse. Accessingres.results.at(0)on the stream therefore threw — see the original report in #470.Solution
Explicitly pass
{ stream: false }fromdoGenerateso the underlying service always returns a singleAxChatResponse, matching the cast already used a line below.doStreamcontinues to pass{ stream: true }and is unchanged.Testing
npx vitest run src/aisdk/index.test.ts— 8/8 pass.doGenerateforwardsstream: falsetoai.chat.prompt conversiontest updated to expect the new second argument.Closes #470.