Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2b72e82

Browse files
authored
refactor(stream-text): use parsedArgs and toolName from executeTool (#117)
* fix(stream-text): use parsedArgs and toolName from executeTool in toolResults* fix(stream-text): streamline parsed arguments handling in tool calls
1 parent4fd6e48 commit2b72e82

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

‎packages/stream-text/src/index.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,6 @@ export const streamText = async (options: StreamTextOptions): Promise<StreamText
170170
return
171171
}
172172

173-
consttoolCall=step.choices[state.index].message.tool_calls![id]
174-
try{
175-
toolCall.function.parsed_arguments=JSON.parse(toolCall.function.arguments)asRecord<string,unknown>
176-
}
177-
catch(error){
178-
state.toolCallErrors[id]=errorasError
179-
}
180-
181173
state.endedToolCallIDs.add(id)
182174
state.currentToolID=null
183175
}
@@ -343,24 +335,26 @@ export const streamText = async (options: StreamTextOptions): Promise<StreamText
343335
}
344336

345337
try{
346-
const{ result}=awaitexecuteTool({
338+
const{parsedArgs,result, toolName}=awaitexecuteTool({
347339
abortSignal:options.abortSignal,
348340
messages:options.messages,
349341
toolCall,
350342
tools:options.tools,
351343
})
352344

345+
toolCall.function.parsed_arguments=parsedArgs
346+
353347
state.toolCallResults[id]=result
354348
step.messages.push({
355349
content:result,
356350
role:'tool',
357351
tool_call_id:id,
358352
})
359353
step.toolResults.push({
360-
args:toolCall.function.parsed_arguments,// TODO: useparsedArgs from executeTool
354+
args:parsedArgs,
361355
result,
362356
toolCallId:id,
363-
toolName:toolCall.function.name,// TODO: use toolName from executeTool
357+
toolName,
364358
})
365359
}
366360
catch(error){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp