UNPKG

@ai-sdk/google

Version:

The **[Google Generative AI provider](https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Google Generative AI](https://ai.google/discover/generativeai/)

32 lines (30 loc) 925 B
import type { LanguageModelV3FinishReason } from '@ai-sdk/provider'; import type { GoogleInteractionsStatus } from './google-interactions-prompt'; /* * `tool-calls` is selected when the response includes a client-side function * call. The API itself signals this via `requires_action`, but * `completed + hasFunctionCall` also occurs in practice. */ export function mapGoogleInteractionsFinishReason({ status, hasFunctionCall, }: { status: GoogleInteractionsStatus | string | null | undefined; hasFunctionCall: boolean; }): LanguageModelV3FinishReason['unified'] { switch (status) { case 'completed': return hasFunctionCall ? 'tool-calls' : 'stop'; case 'requires_action': return 'tool-calls'; case 'failed': return 'error'; case 'incomplete': return 'length'; case 'cancelled': return 'other'; case 'in_progress': default: return 'other'; } }