Skip to content
1 min read · 123 words

Function: extractGeminiGeneration()

ts
function extractGeminiGeneration(
  response:
    | {
        candidates?: {
          content?: GeminiContent;
          finishReason?: string;
        }[];
      }
    | undefined,
): {
  finishReason: string | undefined;
  functionCalls: {
    args: Record<string, unknown>;
    name: string;
    thoughtSignature?: string;
  }[];
  reasoning: string;
  text: string;
};

Defined in: src/batteries/llm/gemini_generate_content/helpers.ts:395

Extract text, reasoning, and function calls from a response.

Parameters

ParameterType
response| { candidates?: { content?: GeminiContent; finishReason?: string; }[]; } | undefined

Returns

ts
{
  finishReason: string | undefined;
  functionCalls: {
     args: Record<string, unknown>;
     name: string;
     thoughtSignature?: string;
  }[];
  reasoning: string;
  text: string;
}
NameTypeDefined in
finishReasonstring | undefinedsrc/batteries/llm/gemini_generate_content/helpers.ts:401
functionCalls{ args: Record<string, unknown>; name: string; thoughtSignature?: string; }[]src/batteries/llm/gemini_generate_content/helpers.ts:400
reasoningstringsrc/batteries/llm/gemini_generate_content/helpers.ts:399
textstringsrc/batteries/llm/gemini_generate_content/helpers.ts:398

Remarks

thought: true parts are reasoning and must NOT be concatenated into user-visible text — doing so leaks the model's scratchpad into the answer.