Skip to content

Commit 5b544a4

Browse files
committed
Resolve quick comments
1 parent f64f183 commit 5b544a4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/core/src/utils/openai/streaming.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,21 @@ interface StreamingState {
6868
function processChatCompletionToolCalls(toolCalls: ChatCompletionToolCall[], state: StreamingState): void {
6969
for (const toolCall of toolCalls) {
7070
const index = toolCall.index;
71-
if (index === undefined) continue;
71+
if (index === undefined || !toolCall.function) continue;
7272

7373
// Initialize tool call if this is the first chunk for this index
7474
if (!(index in state.chatCompletionToolCalls)) {
7575
state.chatCompletionToolCalls[index] = {
7676
...toolCall,
7777
function: {
78-
name: toolCall.function?.name || '',
79-
arguments: toolCall.function?.arguments || '',
78+
name: toolCall.function.name,
79+
arguments: toolCall.function.arguments || '',
8080
},
8181
};
8282
} else {
8383
// Accumulate function arguments from subsequent chunks
8484
const existingToolCall = state.chatCompletionToolCalls[index];
85-
if (toolCall.function?.arguments && existingToolCall?.function) {
85+
if (toolCall.function.arguments && existingToolCall?.function) {
8686
existingToolCall.function.arguments += toolCall.function.arguments;
8787
}
8888
}
@@ -169,7 +169,7 @@ function processResponsesApiEvent(
169169
if (recordOutputs) {
170170
// Handle tool call events for Responses API
171171
if (event.type === 'response.output_item.done' && 'item' in event) {
172-
state.responsesApiToolCalls.push(event.item as ResponseFunctionCall | unknown);
172+
state.responsesApiToolCalls.push(event.item);
173173
}
174174

175175
if (event.type === 'response.output_text.delta' && 'delta' in event && event.delta) {

packages/core/src/utils/openai/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export interface ChatCompletionToolCall {
251251
index?: number; // Present for streaming responses
252252
id: string;
253253
type?: string; // Could be missing for streaming responses
254-
function: {
254+
function?: {
255255
name: string;
256256
arguments?: string;
257257
};

0 commit comments

Comments
 (0)