diff options
| author | Jacob Richman <[email protected]> | 2025-05-29 22:30:18 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-29 15:30:18 -0700 |
| commit | dab7517622527a70bf2f36a9d7a9fa5e1a3b56e0 (patch) | |
| tree | 55b5c8f39b6e7e4fbc28c8a427247e7feb8927ae /packages/cli/src/ui/hooks/useGeminiStream.ts | |
| parent | f21abdd1f0390ba985ae3bec5c29270b9b953b8d (diff) | |
Refactor read-file and support images. (#480)
Diffstat (limited to 'packages/cli/src/ui/hooks/useGeminiStream.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useGeminiStream.ts | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index d91eea3d..afaf0ccd 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -41,6 +41,18 @@ import { useLogger } from './useLogger.js'; import { useToolScheduler, mapToDisplay } from './useToolScheduler.js'; import { GeminiChat } from '@gemini-code/server/src/core/geminiChat.js'; +export function mergePartListUnions(list: PartListUnion[]): PartListUnion { + const resultParts: PartListUnion = []; + for (const item of list) { + if (Array.isArray(item)) { + resultParts.push(...item); + } else { + resultParts.push(item); + } + } + return resultParts; +} + enum StreamProcessingStatus { Completed, UserCancelled, @@ -74,16 +86,16 @@ export const useGeminiStream = ( (tools) => { if (tools.length) { addItem(mapToDisplay(tools), Date.now()); - submitQuery( - tools - .filter( - (t) => - t.status === 'error' || - t.status === 'cancelled' || - t.status === 'success', - ) - .map((t) => t.response.responsePart), - ); + const toolResponses = tools + .filter( + (t) => + t.status === 'error' || + t.status === 'cancelled' || + t.status === 'success', + ) + .map((t) => t.response.responseParts); + + submitQuery(mergePartListUnions(toolResponses)); } }, config, @@ -313,7 +325,7 @@ export const useGeminiStream = ( }; const responseInfo: ToolCallResponseInfo = { callId: request.callId, - responsePart: functionResponse, + responseParts: functionResponse, resultDisplay, error: new Error(declineMessage), }; |
