|
@@ -426,7 +426,8 @@ export function ChatProvider({ children }: ChatProviderProps) {
|
|
|
const finishReason = typeof chunk.finish_reason === 'string'
|
|
const finishReason = typeof chunk.finish_reason === 'string'
|
|
|
? parseInt(chunk.finish_reason, 10)
|
|
? parseInt(chunk.finish_reason, 10)
|
|
|
: chunk.finish_reason
|
|
: chunk.finish_reason
|
|
|
- if (finishReason === 2 && newToolCalls.length > 0) {
|
|
|
|
|
|
|
+ // finish_reason 3 = FINISH_REASON_TOOL_USE per proto enum
|
|
|
|
|
+ if (finishReason === 3 && newToolCalls.length > 0) {
|
|
|
hasMoreToolCalls = true
|
|
hasMoreToolCalls = true
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -498,6 +499,7 @@ export function ChatProvider({ children }: ChatProviderProps) {
|
|
|
}
|
|
}
|
|
|
// Collect tool calls
|
|
// Collect tool calls
|
|
|
if (chunk.tool_call) {
|
|
if (chunk.tool_call) {
|
|
|
|
|
+ console.log('[Chat] Tool call received:', chunk.tool_call)
|
|
|
collectedToolCalls.push(chunk.tool_call)
|
|
collectedToolCalls.push(chunk.tool_call)
|
|
|
}
|
|
}
|
|
|
if (chunk.finish_reason) {
|
|
if (chunk.finish_reason) {
|
|
@@ -505,9 +507,14 @@ export function ChatProvider({ children }: ChatProviderProps) {
|
|
|
finishReasonValue = typeof chunk.finish_reason === 'string'
|
|
finishReasonValue = typeof chunk.finish_reason === 'string'
|
|
|
? parseInt(chunk.finish_reason, 10)
|
|
? parseInt(chunk.finish_reason, 10)
|
|
|
: chunk.finish_reason
|
|
: chunk.finish_reason
|
|
|
- // Check if tool use is needed (finish_reason 2 = FINISH_REASON_TOOL_USE)
|
|
|
|
|
- if (finishReasonValue === 2 && collectedToolCalls.length > 0) {
|
|
|
|
|
|
|
+ console.log('[Chat] Stream finished:', {
|
|
|
|
|
+ finishReason: finishReasonValue,
|
|
|
|
|
+ toolCallsCollected: collectedToolCalls.length
|
|
|
|
|
+ })
|
|
|
|
|
+ // Check if tool use is needed (finish_reason 3 = FINISH_REASON_TOOL_USE per proto enum)
|
|
|
|
|
+ if (finishReasonValue === 3 && collectedToolCalls.length > 0) {
|
|
|
needsToolProcessing = true
|
|
needsToolProcessing = true
|
|
|
|
|
+ console.log('[Chat] Tool processing needed, collected tool calls:', collectedToolCalls)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|