From efc0e73dcc587fe42ff0a637a236f6bc687dc665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=97=8D+85CD?= <50108258+kwaa@users.noreply.github.com> Date: Wed, 12 Nov 2025 18:42:10 +0800 Subject: [PATCH] refactor: simplify code --- packages-ext/telemetry/src/utils/stream-text.ts | 3 +-- packages/stream-text/src/index.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages-ext/telemetry/src/utils/stream-text.ts b/packages-ext/telemetry/src/utils/stream-text.ts index 32a5b19..899239d 100644 --- a/packages-ext/telemetry/src/utils/stream-text.ts +++ b/packages-ext/telemetry/src/utils/stream-text.ts @@ -164,7 +164,6 @@ export const streamText = (options: WithUnknown // https://platform.openai.com/docs/guides/function-calling?api-mode=chat&lang=javascript#streaming for (const toolCall of choice.delta.tool_calls) { const { index } = toolCall - const toolName = toolCall.function.name! if (!tool_calls.at(index)) { tool_calls[index] = { @@ -174,7 +173,7 @@ export const streamText = (options: WithUnknown arguments: toolCall.function.arguments!, }, } - pushEvent({ toolCallId: toolCall.id, toolName, type: 'tool-call-streaming-start' }) + pushEvent({ toolCallId: toolCall.id, toolName: toolCall.function.name!, type: 'tool-call-streaming-start' }) } else { tool_calls[index].function.arguments! += toolCall.function.arguments diff --git a/packages/stream-text/src/index.ts b/packages/stream-text/src/index.ts index fa0cec7..275b4be 100644 --- a/packages/stream-text/src/index.ts +++ b/packages/stream-text/src/index.ts @@ -146,7 +146,6 @@ export const streamText = (options: WithUnknown): StreamTextR // https://platform.openai.com/docs/guides/function-calling?api-mode=chat&lang=javascript#streaming for (const toolCall of choice.delta.tool_calls) { const { index } = toolCall - const toolName = toolCall.function.name! if (!tool_calls.at(index)) { tool_calls[index] = { @@ -156,7 +155,7 @@ export const streamText = (options: WithUnknown): StreamTextR arguments: toolCall.function.arguments!, }, } - pushEvent({ toolCallId: toolCall.id, toolName, type: 'tool-call-streaming-start' }) + pushEvent({ toolCallId: toolCall.id, toolName: toolCall.function.name!, type: 'tool-call-streaming-start' }) } else { tool_calls[index].function.arguments! += toolCall.function.arguments