Add wrapAISDKModel
method for Vercel's AI SDK
#896
Merged
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.
Improve support for tracing Vercel AI SDK calls with a new
wrapAISDKModel
methodBecause AI SDK calls nest the text/object stream within the response, this PR adds an optional parameter to
traceable
that specifies a key in the response object to wrap. It also adds support for specially tappingReadableStream
so thattraceable
does not change them to plain async iterators.Here's an example:
TODO: improve support in the UI for properly rendering token counts and aggregating chunks. The data is returned but is not in one of our currently supported formats.
Example traces:
Generate text: https://smith.langchain.com/public/fbd12847-9485-43cf-a0a3-82c0b3318594/r
Generate object: https://smith.langchain.com/public/c25944c7-2428-44d0-991b-ef3b5e47cab5/r
Stream text: https://smith.langchain.com/public/2fb34c85-fec5-4361-a487-ffcf67718750/r
Stream object: https://smith.langchain.com/public/27f5c9ba-006d-4a2f-b569-2e8da09dae23/r
CC @dqbd