@ai-sdk/google 4.0.87 → 4.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/index.d.ts +23 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -29
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +20 -3
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +68 -23
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +30 -16
- package/package.json +5 -5
- package/src/google-batch.ts +4 -0
- package/src/google-image-model.ts +1 -0
- package/src/google-image-settings.ts +1 -0
- package/src/google-language-model-options.ts +1 -0
- package/src/google-language-model.ts +92 -4
- package/src/google-provider.ts +20 -7
- package/src/interactions/google-interactions-language-model-options.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.89
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fc1e19e: fix: limit jsonl rows to 64mb during batch result downloads
|
|
8
|
+
- 8c0e699: feat(google): preserve file search custom metadata in retrieved context grounding chunks
|
|
9
|
+
- 753f2e1: feat(google): add the 'gemini-nano-banana-2.1' model ID
|
|
10
|
+
- 268225c: feat(provider): add a portable `max` reasoning level with native provider mappings, compatibility coercions, and budget-based fallback support.
|
|
11
|
+
|
|
12
|
+
Compatibility notes:
|
|
13
|
+
|
|
14
|
+
- **TypeScript source compatibility:** Adding `max` widens `LanguageModelV4CallOptions['reasoning']` and the derived `ReasoningLevel` type. Third-party providers and consumers with exhaustive switches or `Record<ReasoningLevel, ...>` mappings must handle `max` before upgrading. Ordinary calls using existing reasoning levels remain accepted.
|
|
15
|
+
- **Amazon Bedrock:** Existing Nova 2 calls using portable `reasoning: 'xhigh'` now send `maxReasoningEffort: 'high'` instead of the unsupported `'max'`, and return a compatibility warning. Anthropic and OpenAI Bedrock effort mappings retain their existing `xhigh` behavior. Partial Bedrock reasoning configurations continue to preserve explicit values and derive missing fields; explicit effort/budget overrides and disabled thinking no longer emit warnings for portable mappings that are not sent.
|
|
16
|
+
- **Fireworks:** Existing portable `minimal` and `xhigh` calls keep their request mappings to `low` and `high`, respectively, and now return compatibility warnings in generation and streaming results. Portable `max` maps to `high` with the same warning behavior.
|
|
17
|
+
|
|
18
|
+
**Release classification:** This remains a patch changeset under the repository's explicit release policy, which uses patch releases for both fixes and features. The TypeScript source-compatibility caveat for exhaustive consumers is disclosed above. Maintainers can override this classification with a `major` label if they decide to align the provider-spec addition with a future AI SDK major release.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [fc1e19e]
|
|
21
|
+
- Updated dependencies [5094ebd]
|
|
22
|
+
- Updated dependencies [268225c]
|
|
23
|
+
- Updated dependencies [0af2f7c]
|
|
24
|
+
- @ai-sdk/provider-utils@5.0.55
|
|
25
|
+
- @ai-sdk/provider@4.0.23
|
|
26
|
+
|
|
27
|
+
## 4.0.88
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 2959d35: feat: rename `evaluate` to `decide`
|
|
32
|
+
- 59116e6: fix(groq,google): use JSON response tool for structured outputs with tool calling
|
|
33
|
+
- Updated dependencies [2959d35]
|
|
34
|
+
- Updated dependencies [59116e6]
|
|
35
|
+
- @ai-sdk/provider@4.0.22
|
|
36
|
+
- @ai-sdk/provider-utils@5.0.54
|
|
37
|
+
|
|
3
38
|
## 4.0.87
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FetchFunction, InferSchema, Resolvable, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, WebSocketConstructor, createToolNameMapping } from "@ai-sdk/provider-utils";
|
|
2
|
-
import { EmbeddingModelV4, Experimental_BatchV4,
|
|
2
|
+
import { EmbeddingModelV4, Experimental_BatchV4, Experimental_DecisionModelV4, Experimental_RealtimeFactoryV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4SessionConfig, Experimental_SpeechTranslationModelV4, Experimental_SpeechTranslationModelV4StreamOptions, Experimental_TranscriptionModelV4StreamOptions, Experimental_VideoModelV4, FilesV4, ImageModelV4, JSONObject, LanguageModelV4, ProviderV4, SpeechModelV4, TranscriptionModelV4 } from "@ai-sdk/provider";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/google-error.d.ts
|
|
5
5
|
declare const googleErrorDataSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
@@ -13,7 +13,7 @@ declare const googleErrorDataSchema: import("@ai-sdk/provider-utils").LazySchema
|
|
|
13
13
|
type GoogleErrorData = InferSchema<typeof googleErrorDataSchema>;
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/google-language-model-options.d.ts
|
|
16
|
-
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
16
|
+
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'gemini-nano-banana-2.1' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
17
17
|
declare const googleLanguageModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
18
18
|
responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
|
|
19
19
|
thinkingConfig?: {
|
|
@@ -143,6 +143,14 @@ declare const responseSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
|
143
143
|
title?: string | null | undefined;
|
|
144
144
|
text?: string | null | undefined;
|
|
145
145
|
fileSearchStore?: string | null | undefined;
|
|
146
|
+
customMetadata?: {
|
|
147
|
+
key: string;
|
|
148
|
+
stringValue?: string | null | undefined;
|
|
149
|
+
numericValue?: number | null | undefined;
|
|
150
|
+
stringListValue?: {
|
|
151
|
+
values?: string[] | null | undefined;
|
|
152
|
+
} | null | undefined;
|
|
153
|
+
}[] | null | undefined;
|
|
146
154
|
} | null | undefined;
|
|
147
155
|
maps?: {
|
|
148
156
|
uri?: string | null | undefined;
|
|
@@ -342,7 +350,7 @@ type GoogleFilesUploadOptions = {
|
|
|
342
350
|
* the two surfaces (`:generateContent` vs `/interactions`) are independent and
|
|
343
351
|
* may diverge over time.
|
|
344
352
|
*/
|
|
345
|
-
type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
353
|
+
type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'gemini-nano-banana-2.1' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
346
354
|
/**
|
|
347
355
|
* Provider options for an individual video file part sent to the Gemini
|
|
348
356
|
* Interactions API.
|
|
@@ -582,7 +590,7 @@ declare const googleTools: {
|
|
|
582
590
|
};
|
|
583
591
|
//#endregion
|
|
584
592
|
//#region src/google-image-settings.d.ts
|
|
585
|
-
type GoogleImageModelId = 'gemini-2.5-flash-image' | 'gemini-3-pro-image-preview' | 'gemini-3.1-flash-image-preview' | (string & {});
|
|
593
|
+
type GoogleImageModelId = 'gemini-2.5-flash-image' | 'gemini-3-pro-image-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-nano-banana-2.1' | (string & {});
|
|
586
594
|
interface GoogleImageSettings {
|
|
587
595
|
/**
|
|
588
596
|
* Override the maximum number of images per call (default 1)
|
|
@@ -621,8 +629,12 @@ interface GoogleProvider extends ProviderV4 {
|
|
|
621
629
|
(modelId: GoogleModelId): LanguageModelV4;
|
|
622
630
|
languageModel(modelId: GoogleModelId): LanguageModelV4;
|
|
623
631
|
chat(modelId: GoogleModelId): LanguageModelV4;
|
|
624
|
-
/** Creates an experimental Choice/Score/Boolean
|
|
625
|
-
|
|
632
|
+
/** Creates an experimental Choice/Score/Boolean decision model using Gemini. */
|
|
633
|
+
decisionModel(modelId: GoogleModelId): Experimental_DecisionModelV4;
|
|
634
|
+
/** @deprecated Use `decisionModel` instead. */
|
|
635
|
+
evaluationModel(modelId: GoogleModelId): Experimental_DecisionModelV4 & {
|
|
636
|
+
doEvaluate: Experimental_DecisionModelV4['doDecide'];
|
|
637
|
+
};
|
|
626
638
|
experimental_batch(): Experimental_BatchV4<{
|
|
627
639
|
text: GoogleModelId;
|
|
628
640
|
image: GoogleImageModelId;
|
|
@@ -704,6 +716,11 @@ interface GoogleProvider extends ProviderV4 {
|
|
|
704
716
|
tools: typeof googleTools;
|
|
705
717
|
}
|
|
706
718
|
interface GoogleProviderSettings {
|
|
719
|
+
/** Settings for downloading JSON Lines batch results. */
|
|
720
|
+
batchResultDownloads?: {
|
|
721
|
+
/** Maximum UTF-8 bytes per row, excluding LF. Defaults to 64 MiB. */
|
|
722
|
+
maxLineBytes?: number;
|
|
723
|
+
};
|
|
707
724
|
/**
|
|
708
725
|
* Use a different URL prefix for API calls, e.g. to use proxy servers.
|
|
709
726
|
* The default prefix is `https://generativelanguage.googleapis.com/v1beta`.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["DecisionModelV4","BatchV4","SpeechTranslationModelV4","RealtimeFactoryV4","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4SessionConfig","TranscriptionModelV4StreamOptions","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/google-error.ts","../src/google-language-model-options.ts","../src/google-language-model.ts","../src/google-prompt.ts","../src/tool/google-search.ts","../src/google-image-model-options.ts","../src/google-embedding-model-options.ts","../src/google-video-model-options.ts","../src/google-video-settings.ts","../src/google-speech-model-options.ts","../src/google-files.ts","../src/interactions/google-interactions-language-model-options.ts","../src/interactions/google-interactions-provider-metadata.ts","../src/interactions/google-interactions-agent.ts","../src/google-tools.ts","../src/google-image-settings.ts","../src/transcription/google-transcription-model-options.ts","../src/speech-translation/google-speech-translation-model-options.ts","../src/google-provider.ts","../src/realtime/google-realtime-model.ts","../src/realtime/google-realtime-model-options.ts","../src/transcription/google-transcription-model.ts","../src/speech-translation/google-speech-translation-model.ts","../src/version.ts"],"mappings":";;;;cAQM,wDAAqB;;;;;;;;KAaf,kBAAkB,mBAAmB;;;KCdrC;cAoDC,6DAA0B;;;;;;;;;;;;;;;WAA1B;;;;;;;;;;;;;;;;;;;;;;;KAkOD,6BAA6B,mBAChC;;;cCqgDI,iDAAc;;;cAAd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BR,kBAAkB,YACrB,mBAAmB;KAGT,0BAA0B,YACpC;KAGU,2BAA2B,YACrC;KAGU,qBAAqB,YAC/B;KAGU,uBAAuB,YACjC,mBAAmB;KAGT,sBAAsB,YAChC,mBAAmB;;;KChwDT,0BAA0B;KAE1B,2BAA2B;KAE3B,qBAAqB;KAErB,uBAAuB;KAEvB,sBAAsB;UAEjB;EACf,gBAAgB;EAChB,mBAAmB;EACnB,oBAAoB;EACpB,eAAe;EACf,eAAe;EACf;EACA;EACA;;;;cC1FW,gCAA8B,EAAA;;;;;;;;;GAczC,EAAA,KAAA;KAEU,uBAAuB,EAAE,aAC5B;;;KCHG,0BAA0B,KACpC;EAGA,eAAe;;;;KCtBL;cAsBC,8DAA2B;;;;;;;;;;;;;;;;;KAkD5B,8BAA8B,mBACjC;;;KC7EG;E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A,eAAe;EACf,YAAY;EACZ;IACE,oBAAoB;IACpB;;;cAIS,wCAAwCE;WAC1C;WACA,SAAS;mBAED;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;MAIG;EAKF,YAAA,SAAS,gCACT,QAAQ;EAMJ,SACJ,SAASD,qDACR,QAAQ,QAAQ,WAAWC;;;;qBCpHnB"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createNullLanguageModelUsage, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, delay, detectMediaType, downloadBlob, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, isAbortError, isCustomReasoning, isFullMediaType, isRecord, isSameOrigin, isUrlSupported, lazySchema, loadApiKey, mapReasoningToProviderBudget, mapReasoningToProviderEffort, normalizeBatchRequestCounts, parseProviderOptions, postJsonToApi, postToApi, resolve, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, secureJsonParse, serializeModelOptions, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
-
import {
|
|
1
|
+
import { EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertJsonResponseToolStream, convertToBase64, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createNullLanguageModelUsage, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, delay, detectMediaType, downloadBlob, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, isAbortError, isCustomReasoning, isFullMediaType, isRecord, isSameOrigin, isUrlSupported, lazySchema, loadApiKey, mapReasoningToProviderBudget, mapReasoningToProviderEffort, normalizeBatchRequestCounts, parseProviderOptions, postJsonToApi, postToApi, resolve, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, secureJsonParse, serializeModelOptions, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { Experimental_DecisionLanguageModel } from "@ai-sdk/provider-utils/experimental-decision";
|
|
3
3
|
import { AISDKError, InvalidArgumentError, InvalidResponseDataError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
//#region src/version.ts
|
|
6
|
-
const VERSION = "4.0.
|
|
6
|
+
const VERSION = "4.0.89";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/google-error.ts
|
|
9
9
|
const googleErrorDataSchema = lazySchema(() => zodSchema(z.object({ error: z.object({
|
|
@@ -1546,15 +1546,38 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1546
1546
|
toolNameMapping
|
|
1547
1547
|
};
|
|
1548
1548
|
}
|
|
1549
|
-
getArgs(options, { isStreaming = false } = {}) {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1549
|
+
async getArgs(options, { isStreaming = false } = {}) {
|
|
1550
|
+
const { responseFormat, tools, toolChoice } = options;
|
|
1551
|
+
let jsonResponseTool;
|
|
1552
|
+
if (responseFormat?.type === "json" && responseFormat.schema != null && tools?.some((tool) => tool.type === "function") && /(^|\/)gemini-/i.test(this.modelId) && (!getGoogleModelCapabilities(this.modelId).usesGemini3Features || toolChoice?.type === "required" || toolChoice?.type === "tool")) {
|
|
1553
|
+
let name = "json";
|
|
1554
|
+
for (let suffix = 1; tools.some((tool) => tool.name === name); suffix++) name = `json_${suffix}`;
|
|
1555
|
+
jsonResponseTool = {
|
|
1556
|
+
type: "function",
|
|
1557
|
+
name,
|
|
1558
|
+
description: responseFormat.description ?? "Respond with a JSON object.",
|
|
1559
|
+
inputSchema: responseFormat.schema
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
return {
|
|
1563
|
+
...await GoogleLanguageModel.prepareRequest({
|
|
1564
|
+
modelId: this.modelId,
|
|
1565
|
+
config: this.config,
|
|
1566
|
+
options: jsonResponseTool == null ? options : {
|
|
1567
|
+
...options,
|
|
1568
|
+
responseFormat: void 0,
|
|
1569
|
+
tools: [...tools ?? [], jsonResponseTool],
|
|
1570
|
+
toolChoice: toolChoice?.type === "tool" ? toolChoice : toolChoice?.type === "none" ? {
|
|
1571
|
+
type: "tool",
|
|
1572
|
+
toolName: jsonResponseTool.name
|
|
1573
|
+
} : { type: "required" }
|
|
1574
|
+
},
|
|
1575
|
+
isStreaming
|
|
1576
|
+
}),
|
|
1577
|
+
jsonResponseToolName: jsonResponseTool?.name
|
|
1578
|
+
};
|
|
1556
1579
|
}
|
|
1557
|
-
static convertGenerateContentResponse({ config, response, warnings, providerOptionsNames, toolNameMapping }) {
|
|
1580
|
+
static convertGenerateContentResponse({ config, response, warnings, providerOptionsNames, toolNameMapping, jsonResponseToolName }) {
|
|
1558
1581
|
const wrapProviderMetadata = (payload) => Object.fromEntries(providerOptionsNames.map((name) => [name, payload]));
|
|
1559
1582
|
const candidate = response.candidates?.[0];
|
|
1560
1583
|
const promptBlockReason = response.promptFeedback?.blockReason;
|
|
@@ -1586,6 +1609,7 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1586
1609
|
}
|
|
1587
1610
|
});
|
|
1588
1611
|
else if ("text" in part && part.text != null) {
|
|
1612
|
+
if (jsonResponseToolName != null && part.thought !== true) continue;
|
|
1589
1613
|
const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({ thoughtSignature: part.thoughtSignature }) : void 0;
|
|
1590
1614
|
if (part.text.length === 0) {
|
|
1591
1615
|
if (thoughtSignatureMetadata != null && content.length > 0) {
|
|
@@ -1597,14 +1621,23 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1597
1621
|
text: part.text,
|
|
1598
1622
|
providerMetadata: thoughtSignatureMetadata
|
|
1599
1623
|
});
|
|
1600
|
-
} else if ("functionCall" in part && part.functionCall.name != null)
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1624
|
+
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1625
|
+
if (part.functionCall.name === jsonResponseToolName) {
|
|
1626
|
+
content.push({
|
|
1627
|
+
type: "text",
|
|
1628
|
+
text: typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify(part.functionCall.args ?? {}),
|
|
1629
|
+
...part.thoughtSignature ? { providerMetadata: wrapProviderMetadata({ thoughtSignature: part.thoughtSignature }) } : {}
|
|
1630
|
+
});
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1633
|
+
content.push({
|
|
1634
|
+
type: "tool-call",
|
|
1635
|
+
toolCallId: part.functionCall.id || config.generateId(),
|
|
1636
|
+
toolName: part.functionCall.name,
|
|
1637
|
+
input: JSON.stringify(part.functionCall.args ?? {}),
|
|
1638
|
+
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({ thoughtSignature: part.thoughtSignature }) : void 0
|
|
1639
|
+
});
|
|
1640
|
+
} else if ("inlineData" in part) {
|
|
1608
1641
|
const hasThought = part.thought === true;
|
|
1609
1642
|
const hasThoughtSignature = !!part.thoughtSignature;
|
|
1610
1643
|
content.push({
|
|
@@ -1682,7 +1715,7 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1682
1715
|
};
|
|
1683
1716
|
}
|
|
1684
1717
|
async doGenerate(options) {
|
|
1685
|
-
const { args, warnings, providerOptionsNames, extraHeaders, toolNameMapping } = await this.getArgs(options);
|
|
1718
|
+
const { args, warnings, providerOptionsNames, extraHeaders, toolNameMapping, jsonResponseToolName } = await this.getArgs(options);
|
|
1686
1719
|
const mergedHeaders = combineHeaders(this.config.headers ? await resolve(this.config.headers) : void 0, options.headers, extraHeaders);
|
|
1687
1720
|
const { responseHeaders, value: response, rawValue: rawResponse } = await postJsonToApi({
|
|
1688
1721
|
url: `${this.config.baseURL}/${getModelPath(this.modelId)}:generateContent`,
|
|
@@ -1698,7 +1731,8 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1698
1731
|
response,
|
|
1699
1732
|
warnings,
|
|
1700
1733
|
providerOptionsNames,
|
|
1701
|
-
toolNameMapping
|
|
1734
|
+
toolNameMapping,
|
|
1735
|
+
jsonResponseToolName
|
|
1702
1736
|
});
|
|
1703
1737
|
return {
|
|
1704
1738
|
...result,
|
|
@@ -1711,7 +1745,7 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1711
1745
|
};
|
|
1712
1746
|
}
|
|
1713
1747
|
async doStream(options) {
|
|
1714
|
-
const { args, warnings, providerOptionsNames, extraHeaders, toolNameMapping } = await this.getArgs(options, { isStreaming: true });
|
|
1748
|
+
const { args, warnings, providerOptionsNames, extraHeaders, toolNameMapping, jsonResponseToolName } = await this.getArgs(options, { isStreaming: true });
|
|
1715
1749
|
const wrapProviderMetadata = (payload) => Object.fromEntries(providerOptionsNames.map((name) => [name, payload]));
|
|
1716
1750
|
const headers = combineHeaders(this.config.headers ? await resolve(this.config.headers) : void 0, options.headers, extraHeaders);
|
|
1717
1751
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
@@ -1768,7 +1802,7 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
1768
1802
|
});
|
|
1769
1803
|
hasToolCalls = true;
|
|
1770
1804
|
};
|
|
1771
|
-
|
|
1805
|
+
const result = {
|
|
1772
1806
|
stream: response.pipeThrough(new TransformStream({
|
|
1773
1807
|
start(controller) {
|
|
1774
1808
|
controller.enqueue({
|
|
@@ -2100,6 +2134,10 @@ var GoogleLanguageModel = class GoogleLanguageModel {
|
|
|
2100
2134
|
response: { headers: responseHeaders },
|
|
2101
2135
|
request: { body: args }
|
|
2102
2136
|
};
|
|
2137
|
+
return {
|
|
2138
|
+
...result,
|
|
2139
|
+
stream: jsonResponseToolName == null ? result.stream : result.stream.pipeThrough(convertJsonResponseToolStream(jsonResponseToolName))
|
|
2140
|
+
};
|
|
2103
2141
|
}
|
|
2104
2142
|
};
|
|
2105
2143
|
function getMaxOutputTokensForGemini25Model() {
|
|
@@ -2133,7 +2171,8 @@ function resolveGemini3ThinkingConfig({ reasoning, modelId, warnings }) {
|
|
|
2133
2171
|
low: "low",
|
|
2134
2172
|
medium: "medium",
|
|
2135
2173
|
high: "high",
|
|
2136
|
-
xhigh: "high"
|
|
2174
|
+
xhigh: "high",
|
|
2175
|
+
max: "high"
|
|
2137
2176
|
},
|
|
2138
2177
|
warnings
|
|
2139
2178
|
});
|
|
@@ -2258,7 +2297,13 @@ const getGroundingMetadataSchema = () => z.object({
|
|
|
2258
2297
|
uri: z.string().nullish(),
|
|
2259
2298
|
title: z.string().nullish(),
|
|
2260
2299
|
text: z.string().nullish(),
|
|
2261
|
-
fileSearchStore: z.string().nullish()
|
|
2300
|
+
fileSearchStore: z.string().nullish(),
|
|
2301
|
+
customMetadata: z.array(z.object({
|
|
2302
|
+
key: z.string(),
|
|
2303
|
+
stringValue: z.string().nullish(),
|
|
2304
|
+
numericValue: z.number().nullish(),
|
|
2305
|
+
stringListValue: z.object({ values: z.array(z.string()).nullish() }).nullish()
|
|
2306
|
+
})).nullish()
|
|
2262
2307
|
}).nullish(),
|
|
2263
2308
|
maps: z.object({
|
|
2264
2309
|
uri: z.string().nullish(),
|
|
@@ -2510,6 +2555,7 @@ var GoogleBatch = class {
|
|
|
2510
2555
|
this.batchConfig = options.config;
|
|
2511
2556
|
this.supportedUrls = options.supportedUrls;
|
|
2512
2557
|
this.batchGenerateId = options.config.generateId ?? generateId;
|
|
2558
|
+
this.maxLineBytes = options.maxLineBytes;
|
|
2513
2559
|
}
|
|
2514
2560
|
async doStartBatch(options) {
|
|
2515
2561
|
assertSupportedBatchRequests(options.requests);
|
|
@@ -2706,7 +2752,7 @@ var GoogleBatch = class {
|
|
|
2706
2752
|
url: `${this.getBaseOrigin()}/download/v1beta/${encodedResponsesFile}:download?alt=media`,
|
|
2707
2753
|
headers: await this.getHeaders(options.headers),
|
|
2708
2754
|
failedResponseHandler: googleFailedResponseHandler,
|
|
2709
|
-
successfulResponseHandler: createJsonLinesResponseHandler(googleBatchResultLineSchema),
|
|
2755
|
+
successfulResponseHandler: createJsonLinesResponseHandler(googleBatchResultLineSchema, { maxLineBytes: this.maxLineBytes }),
|
|
2710
2756
|
abortSignal: options.abortSignal,
|
|
2711
2757
|
fetch: this.batchConfig.fetch,
|
|
2712
2758
|
validateUrl: false
|
|
@@ -3102,7 +3148,8 @@ const googleTools = {
|
|
|
3102
3148
|
const googleImageModelsWithFileInputSupport = /* @__PURE__ */ new Set([
|
|
3103
3149
|
"gemini-2.5-flash-image",
|
|
3104
3150
|
"gemini-3-pro-image-preview",
|
|
3105
|
-
"gemini-3.1-flash-image-preview"
|
|
3151
|
+
"gemini-3.1-flash-image-preview",
|
|
3152
|
+
"gemini-nano-banana-2.1"
|
|
3106
3153
|
]);
|
|
3107
3154
|
var GoogleImageModel = class GoogleImageModel {
|
|
3108
3155
|
static [WORKFLOW_SERIALIZE](model) {
|
|
@@ -7975,6 +8022,7 @@ function createGoogle(options = {}) {
|
|
|
7975
8022
|
});
|
|
7976
8023
|
const createBatch = () => new GoogleBatch({
|
|
7977
8024
|
provider: `${providerName.replace(/\.generative-ai$/, "")}.batch`,
|
|
8025
|
+
maxLineBytes: options.batchResultDownloads?.maxLineBytes,
|
|
7978
8026
|
config: languageModelConfig,
|
|
7979
8027
|
supportedUrls: getSupportedUrls(void 0, false)
|
|
7980
8028
|
});
|
|
@@ -8054,10 +8102,11 @@ function createGoogle(options = {}) {
|
|
|
8054
8102
|
provider.languageModel = createChatModel;
|
|
8055
8103
|
provider.chat = createChatModel;
|
|
8056
8104
|
provider.generativeAI = createChatModel;
|
|
8057
|
-
provider.
|
|
8105
|
+
provider.decisionModel = (modelId) => new Experimental_DecisionLanguageModel({
|
|
8058
8106
|
model: createChatModel(modelId),
|
|
8059
|
-
provider: `${providerName.replace(/\.generative-ai$/, "")}.
|
|
8107
|
+
provider: `${providerName.replace(/\.generative-ai$/, "")}.decision`
|
|
8060
8108
|
});
|
|
8109
|
+
provider.evaluationModel = provider.decisionModel;
|
|
8061
8110
|
provider.experimental_batch = createBatch;
|
|
8062
8111
|
provider.embedding = createEmbeddingModel;
|
|
8063
8112
|
provider.embeddingModel = createEmbeddingModel;
|