-
Notifications
You must be signed in to change notification settings - Fork 351
fix(ai): fix streamed tool call parsing, tool call arguments in v5 #6813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+15
−16
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
36565da
fix tool call arguments parsing for v5
sabrenner e707b38
fix tool call streaming and re-enable test
sabrenner d635f8c
update assertion
sabrenner 45223b1
Merge branch 'master' of github.com:DataDog/dd-trace-js into sabrenne…
sabrenner dba0920
fix remaining tests
sabrenner 113f0ba
Merge branch 'master' into sabrenner/fix-vercel-ai
sabrenner c31aa3e
Merge branch 'master' into sabrenner/fix-vercel-ai
sabrenner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -346,8 +346,7 @@ describe('Plugin', () => { | |
| }) | ||
| }) | ||
|
|
||
| // TODO(sabrenner): Fix this test for v5.0.0 - tool "input" instead of "arguments" | ||
| it.skip('creates a span for a tool call', async () => { // eslint-disable-line mocha/no-pending-tests | ||
| it('creates a span for a tool call', async () => { | ||
| let tools | ||
| let additionalOptions = {} | ||
| const toolSchema = ai.jsonSchema({ | ||
|
|
@@ -504,8 +503,7 @@ describe('Plugin', () => { | |
| }) | ||
| }) | ||
|
|
||
| // TODO(sabrenner): Fix this test for v5.0.0 - tool "input" instead of "arguments" & parsing, streaming | ||
| it.skip('created a span for a tool call from a stream', async () => { // eslint-disable-line mocha/no-pending-tests | ||
| it('created a span for a tool call from a stream', async () => { | ||
| let tools | ||
| let additionalOptions = {} | ||
| const toolSchema = ai.jsonSchema({ | ||
|
|
@@ -629,15 +627,13 @@ describe('Plugin', () => { | |
| span: apmSpans[2], | ||
| parentId: llmobsSpans[0].span_id, | ||
| /** | ||
| * MOCK_STRING used as the stream implementation for ai does not finish the initial llm spans | ||
| * Before [email protected], the stream implementation did not finish the initial llm spans | ||
| * first to associate the tool call id with the tool itself (by matching descriptions). | ||
| * | ||
| * Usually, this would mean the tool call name is 'toolCall'. | ||
| * | ||
| * However, because we used mocked responses, the second time this test is called, the tool call | ||
| * will have the name 'weather' instead. We just assert that the name exists and is a string to simplify. | ||
| * Usually, this would mean the tool call name is 'toolCall'. This is a limitation with the older library | ||
| * versions. In v5+, this is resolved as the tool name is not its index in the tools array, but its actual name. | ||
| */ | ||
| name: MOCK_STRING, | ||
| name: semifies(realVersion, NODE_MAJOR < 22 ? '<=4.0.2' : '<4.0.2') ? 'toolCall' : 'weather', | ||
| spanKind: 'tool', | ||
| inputValue: JSON.stringify({ location: 'Tokyo' }), | ||
| outputValue: JSON.stringify({ location: 'Tokyo', temperature: 72 }), | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.