@ai-sdk/google 3.0.130 → 3.0.132
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 +15 -0
- package/dist/index.d.mts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +225 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +225 -37
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +19 -2
- package/dist/internal/index.d.ts +19 -2
- package/dist/internal/index.js +224 -36
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +224 -36
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +143 -1
- package/package.json +3 -3
- package/src/continue-google-stream.ts +75 -0
- package/src/convert-google-generative-ai-usage.ts +75 -0
- package/src/google-generative-ai-image-settings.ts +1 -0
- package/src/google-generative-ai-language-model.ts +150 -24
- package/src/google-generative-ai-options.ts +13 -0
- package/src/google-generative-ai-prompt.ts +18 -0
- package/src/interactions/google-interactions-language-model-options.ts +2 -0
- package/src/interactions/google-interactions-language-model.ts +6 -6
- package/src/map-google-generative-ai-finish-reason.ts +3 -0
|
@@ -3,7 +3,7 @@ import { Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
|
3
3
|
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
|
-
type GoogleGenerativeAIModelId = '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' | '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 & {});
|
|
6
|
+
type GoogleGenerativeAIModelId = '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-4-argon' | 'gemini-nano-banana-2.1' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | '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 & {});
|
|
7
7
|
|
|
8
8
|
type GoogleGenerativeAIConfig = {
|
|
9
9
|
provider: string;
|
|
@@ -51,6 +51,14 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
|
51
51
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
52
|
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
53
|
fileSearchStore: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
customMetadata: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
55
|
+
key: z.ZodString;
|
|
56
|
+
stringValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
|
+
numericValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
58
|
+
stringListValue: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
59
|
+
values: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
60
|
+
}, z.core.$strip>>>;
|
|
61
|
+
}, z.core.$strip>>>>;
|
|
54
62
|
}, z.core.$strip>>>;
|
|
55
63
|
maps: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
56
64
|
uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -138,6 +146,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
138
146
|
} | null | undefined;
|
|
139
147
|
finishReason?: string | null | undefined;
|
|
140
148
|
finishMessage?: string | null | undefined;
|
|
149
|
+
continuationToken?: string | null | undefined;
|
|
141
150
|
safetyRatings?: {
|
|
142
151
|
category?: string | null | undefined;
|
|
143
152
|
probability?: string | null | undefined;
|
|
@@ -169,6 +178,14 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
169
178
|
title?: string | null | undefined;
|
|
170
179
|
text?: string | null | undefined;
|
|
171
180
|
fileSearchStore?: string | null | undefined;
|
|
181
|
+
customMetadata?: {
|
|
182
|
+
key: string;
|
|
183
|
+
stringValue?: string | null | undefined;
|
|
184
|
+
numericValue?: number | null | undefined;
|
|
185
|
+
stringListValue?: {
|
|
186
|
+
values?: string[] | null | undefined;
|
|
187
|
+
} | null | undefined;
|
|
188
|
+
}[] | null | undefined;
|
|
172
189
|
} | null | undefined;
|
|
173
190
|
maps?: {
|
|
174
191
|
uri?: string | null | undefined;
|
|
@@ -342,7 +359,7 @@ declare const googleTools: {
|
|
|
342
359
|
* the two surfaces (`:generateContent` vs `/interactions`) are independent and
|
|
343
360
|
* may diverge over time.
|
|
344
361
|
*/
|
|
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 & {});
|
|
362
|
+
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-4-argon' | 'gemini-nano-banana-2.1' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
346
363
|
|
|
347
364
|
type GoogleInteractionsConfig = {
|
|
348
365
|
provider: string;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
|
3
3
|
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
|
-
type GoogleGenerativeAIModelId = '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' | '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 & {});
|
|
6
|
+
type GoogleGenerativeAIModelId = '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-4-argon' | 'gemini-nano-banana-2.1' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | '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 & {});
|
|
7
7
|
|
|
8
8
|
type GoogleGenerativeAIConfig = {
|
|
9
9
|
provider: string;
|
|
@@ -51,6 +51,14 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
|
51
51
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
52
|
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
53
|
fileSearchStore: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
customMetadata: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
55
|
+
key: z.ZodString;
|
|
56
|
+
stringValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
|
+
numericValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
58
|
+
stringListValue: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
59
|
+
values: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
60
|
+
}, z.core.$strip>>>;
|
|
61
|
+
}, z.core.$strip>>>>;
|
|
54
62
|
}, z.core.$strip>>>;
|
|
55
63
|
maps: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
56
64
|
uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -138,6 +146,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
138
146
|
} | null | undefined;
|
|
139
147
|
finishReason?: string | null | undefined;
|
|
140
148
|
finishMessage?: string | null | undefined;
|
|
149
|
+
continuationToken?: string | null | undefined;
|
|
141
150
|
safetyRatings?: {
|
|
142
151
|
category?: string | null | undefined;
|
|
143
152
|
probability?: string | null | undefined;
|
|
@@ -169,6 +178,14 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
169
178
|
title?: string | null | undefined;
|
|
170
179
|
text?: string | null | undefined;
|
|
171
180
|
fileSearchStore?: string | null | undefined;
|
|
181
|
+
customMetadata?: {
|
|
182
|
+
key: string;
|
|
183
|
+
stringValue?: string | null | undefined;
|
|
184
|
+
numericValue?: number | null | undefined;
|
|
185
|
+
stringListValue?: {
|
|
186
|
+
values?: string[] | null | undefined;
|
|
187
|
+
} | null | undefined;
|
|
188
|
+
}[] | null | undefined;
|
|
172
189
|
} | null | undefined;
|
|
173
190
|
maps?: {
|
|
174
191
|
uri?: string | null | undefined;
|
|
@@ -342,7 +359,7 @@ declare const googleTools: {
|
|
|
342
359
|
* the two surfaces (`:generateContent` vs `/interactions`) are independent and
|
|
343
360
|
* may diverge over time.
|
|
344
361
|
*/
|
|
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 & {});
|
|
362
|
+
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-4-argon' | 'gemini-nano-banana-2.1' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
346
363
|
|
|
347
364
|
type GoogleInteractionsConfig = {
|
|
348
365
|
provider: string;
|
package/dist/internal/index.js
CHANGED
|
@@ -32,6 +32,53 @@ module.exports = __toCommonJS(index_exports);
|
|
|
32
32
|
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
33
33
|
var import_v43 = require("zod/v4");
|
|
34
34
|
|
|
35
|
+
// src/continue-google-stream.ts
|
|
36
|
+
function continueGoogleStream({
|
|
37
|
+
stream,
|
|
38
|
+
getContinuationToken,
|
|
39
|
+
continueStream
|
|
40
|
+
}) {
|
|
41
|
+
let reader = stream.getReader();
|
|
42
|
+
let pendingContinuationToken;
|
|
43
|
+
return new ReadableStream({
|
|
44
|
+
async pull(controller) {
|
|
45
|
+
while (true) {
|
|
46
|
+
const { done, value } = await reader.read();
|
|
47
|
+
if (!done) {
|
|
48
|
+
if (value.success) {
|
|
49
|
+
const token = getContinuationToken(value.value);
|
|
50
|
+
if (token != null) {
|
|
51
|
+
pendingContinuationToken = token;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
controller.enqueue(value);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (pendingContinuationToken == null) {
|
|
58
|
+
controller.close();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const continuationToken = pendingContinuationToken;
|
|
62
|
+
pendingContinuationToken = void 0;
|
|
63
|
+
try {
|
|
64
|
+
reader = (await continueStream(continuationToken)).getReader();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
controller.enqueue({
|
|
67
|
+
success: false,
|
|
68
|
+
error,
|
|
69
|
+
rawValue: void 0
|
|
70
|
+
});
|
|
71
|
+
controller.close();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
async cancel(reason) {
|
|
77
|
+
await reader.cancel(reason);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
35
82
|
// src/convert-google-generative-ai-usage.ts
|
|
36
83
|
function convertGoogleGenerativeAIUsage(usage) {
|
|
37
84
|
var _a, _b, _c, _d;
|
|
@@ -70,6 +117,63 @@ function convertGoogleGenerativeAIUsage(usage) {
|
|
|
70
117
|
raw: usage
|
|
71
118
|
};
|
|
72
119
|
}
|
|
120
|
+
function addGoogleGenerativeAIUsageMetadata(a, b) {
|
|
121
|
+
if (a == null || b == null) {
|
|
122
|
+
return b != null ? b : a;
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
...a,
|
|
126
|
+
...b,
|
|
127
|
+
promptTokenCount: addCounts(a.promptTokenCount, b.promptTokenCount),
|
|
128
|
+
candidatesTokenCount: addCounts(
|
|
129
|
+
a.candidatesTokenCount,
|
|
130
|
+
b.candidatesTokenCount
|
|
131
|
+
),
|
|
132
|
+
toolUsePromptTokenCount: addCounts(
|
|
133
|
+
a.toolUsePromptTokenCount,
|
|
134
|
+
b.toolUsePromptTokenCount
|
|
135
|
+
),
|
|
136
|
+
totalTokenCount: addCounts(a.totalTokenCount, b.totalTokenCount),
|
|
137
|
+
cachedContentTokenCount: addCounts(
|
|
138
|
+
a.cachedContentTokenCount,
|
|
139
|
+
b.cachedContentTokenCount
|
|
140
|
+
),
|
|
141
|
+
thoughtsTokenCount: addCounts(a.thoughtsTokenCount, b.thoughtsTokenCount),
|
|
142
|
+
promptTokensDetails: addTokenDetails(
|
|
143
|
+
a.promptTokensDetails,
|
|
144
|
+
b.promptTokensDetails
|
|
145
|
+
),
|
|
146
|
+
cacheTokensDetails: addTokenDetails(
|
|
147
|
+
a.cacheTokensDetails,
|
|
148
|
+
b.cacheTokensDetails
|
|
149
|
+
),
|
|
150
|
+
candidatesTokensDetails: addTokenDetails(
|
|
151
|
+
a.candidatesTokensDetails,
|
|
152
|
+
b.candidatesTokensDetails
|
|
153
|
+
),
|
|
154
|
+
toolUsePromptTokensDetails: addTokenDetails(
|
|
155
|
+
a.toolUsePromptTokensDetails,
|
|
156
|
+
b.toolUsePromptTokensDetails
|
|
157
|
+
)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function addCounts(a, b) {
|
|
161
|
+
return a == null && b == null ? b != null ? b : a : (a != null ? a : 0) + (b != null ? b : 0);
|
|
162
|
+
}
|
|
163
|
+
function addTokenDetails(a, b) {
|
|
164
|
+
var _a;
|
|
165
|
+
if (a == null || b == null) {
|
|
166
|
+
return b != null ? b : a;
|
|
167
|
+
}
|
|
168
|
+
const tokenCounts = /* @__PURE__ */ new Map();
|
|
169
|
+
for (const { modality, tokenCount } of [...a, ...b]) {
|
|
170
|
+
tokenCounts.set(modality, ((_a = tokenCounts.get(modality)) != null ? _a : 0) + tokenCount);
|
|
171
|
+
}
|
|
172
|
+
return Array.from(tokenCounts, ([modality, tokenCount]) => ({
|
|
173
|
+
modality,
|
|
174
|
+
tokenCount
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
73
177
|
|
|
74
178
|
// src/convert-json-schema-to-openapi-schema.ts
|
|
75
179
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -980,6 +1084,16 @@ var googleLanguageModelOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
980
1084
|
* `serviceTier` body field. Gemini API only.
|
|
981
1085
|
*/
|
|
982
1086
|
serviceTier: import_v42.z.enum(["standard", "flex", "priority"]).optional(),
|
|
1087
|
+
/**
|
|
1088
|
+
* Optional. Resumes a response that stopped with `MAX_TOKENS` because it
|
|
1089
|
+
* used up its `maxOutputTokens` budget (Gemini 4 long decode). Pass the
|
|
1090
|
+
* `continuationToken` from the previous response's provider metadata
|
|
1091
|
+
* together with the original prompt and a higher `maxOutputTokens` (the
|
|
1092
|
+
* budget is cumulative across requests). Requests that reach the
|
|
1093
|
+
* per-request cap while budget remains (`CONTINUATION`) are continued
|
|
1094
|
+
* automatically. Sent as the `continuationToken` body field.
|
|
1095
|
+
*/
|
|
1096
|
+
continuationToken: import_v42.z.string().optional(),
|
|
983
1097
|
/**
|
|
984
1098
|
* Optional. Vertex AI only. Sent as the
|
|
985
1099
|
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
@@ -1528,6 +1642,9 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
1528
1642
|
case "STOP":
|
|
1529
1643
|
return hasToolCalls ? "tool-calls" : "stop";
|
|
1530
1644
|
case "MAX_TOKENS":
|
|
1645
|
+
// Gemini 4 long decode: the per-request cap was reached while budget
|
|
1646
|
+
// remains. Continued automatically; only surfaced if continuing fails.
|
|
1647
|
+
case "CONTINUATION":
|
|
1531
1648
|
return "length";
|
|
1532
1649
|
case "IMAGE_SAFETY":
|
|
1533
1650
|
case "RECITATION":
|
|
@@ -1759,7 +1876,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1759
1876
|
toolConfig,
|
|
1760
1877
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
1761
1878
|
labels: googleOptions == null ? void 0 : googleOptions.labels,
|
|
1762
|
-
serviceTier: bodyServiceTier
|
|
1879
|
+
serviceTier: bodyServiceTier,
|
|
1880
|
+
...(googleOptions == null ? void 0 : googleOptions.continuationToken) != null && {
|
|
1881
|
+
continuationToken: googleOptions.continuationToken
|
|
1882
|
+
}
|
|
1763
1883
|
},
|
|
1764
1884
|
warnings: [...warnings, ...toolWarnings],
|
|
1765
1885
|
providerOptionsName,
|
|
@@ -1767,42 +1887,66 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1767
1887
|
};
|
|
1768
1888
|
}
|
|
1769
1889
|
async doGenerate(options) {
|
|
1770
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1890
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
|
|
1771
1891
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1772
1892
|
const mergedHeaders = (0, import_provider_utils5.combineHeaders)(
|
|
1773
1893
|
await (0, import_provider_utils5.resolve)(this.config.headers),
|
|
1774
1894
|
options.headers,
|
|
1775
1895
|
extraHeaders
|
|
1776
1896
|
);
|
|
1777
|
-
const {
|
|
1778
|
-
responseHeaders,
|
|
1779
|
-
value: response,
|
|
1780
|
-
rawValue: rawResponse
|
|
1781
|
-
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
1897
|
+
const generateContent = (body) => (0, import_provider_utils5.postJsonToApi)({
|
|
1782
1898
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1783
1899
|
this.modelId
|
|
1784
1900
|
)}:generateContent`,
|
|
1785
1901
|
headers: mergedHeaders,
|
|
1786
|
-
body
|
|
1902
|
+
body,
|
|
1787
1903
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1788
1904
|
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(responseSchema),
|
|
1789
1905
|
abortSignal: options.abortSignal,
|
|
1790
1906
|
fetch: this.config.fetch
|
|
1791
1907
|
});
|
|
1792
|
-
|
|
1793
|
-
|
|
1908
|
+
let {
|
|
1909
|
+
responseHeaders,
|
|
1910
|
+
value: response,
|
|
1911
|
+
rawValue: rawResponse
|
|
1912
|
+
} = await generateContent(args);
|
|
1913
|
+
const continuedParts = [];
|
|
1914
|
+
let continuedUsageMetadata;
|
|
1915
|
+
const firstPromptTokenCount = (_a = response.usageMetadata) == null ? void 0 : _a.promptTokenCount;
|
|
1916
|
+
while (true) {
|
|
1917
|
+
const candidate2 = (_b = response.candidates) == null ? void 0 : _b[0];
|
|
1918
|
+
const continuationToken = (candidate2 == null ? void 0 : candidate2.finishReason) === "CONTINUATION" ? candidate2.continuationToken : void 0;
|
|
1919
|
+
if (continuationToken == null) {
|
|
1920
|
+
break;
|
|
1921
|
+
}
|
|
1922
|
+
continuedParts.push(...(_d = (_c = candidate2 == null ? void 0 : candidate2.content) == null ? void 0 : _c.parts) != null ? _d : []);
|
|
1923
|
+
continuedUsageMetadata = addGoogleGenerativeAIUsageMetadata(
|
|
1924
|
+
continuedUsageMetadata,
|
|
1925
|
+
(_e = response.usageMetadata) != null ? _e : void 0
|
|
1926
|
+
);
|
|
1927
|
+
({
|
|
1928
|
+
responseHeaders,
|
|
1929
|
+
value: response,
|
|
1930
|
+
rawValue: rawResponse
|
|
1931
|
+
} = await generateContent({ ...args, continuationToken }));
|
|
1932
|
+
}
|
|
1933
|
+
const candidate = (_f = response.candidates) == null ? void 0 : _f[0];
|
|
1934
|
+
const promptBlockReason = (_g = response.promptFeedback) == null ? void 0 : _g.blockReason;
|
|
1794
1935
|
const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
|
|
1795
1936
|
promptBlockReason
|
|
1796
1937
|
) ? promptBlockReason : void 0;
|
|
1797
1938
|
const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && confirmedPromptBlockReason != null;
|
|
1798
|
-
const rawFinishReason = (
|
|
1939
|
+
const rawFinishReason = (_h = candidate == null ? void 0 : candidate.finishReason) != null ? _h : confirmedPromptBlockReason;
|
|
1799
1940
|
const content = [];
|
|
1800
|
-
const parts = (
|
|
1801
|
-
const usageMetadata =
|
|
1941
|
+
const parts = [...continuedParts, ...(_j = (_i = candidate == null ? void 0 : candidate.content) == null ? void 0 : _i.parts) != null ? _j : []];
|
|
1942
|
+
const usageMetadata = addGoogleGenerativeAIUsageMetadata(
|
|
1943
|
+
continuedUsageMetadata,
|
|
1944
|
+
(_k = response.usageMetadata) != null ? _k : void 0
|
|
1945
|
+
);
|
|
1802
1946
|
let lastCodeExecutionToolCallId;
|
|
1803
1947
|
let lastServerToolCallId;
|
|
1804
1948
|
for (const part of parts) {
|
|
1805
|
-
if ("executableCode" in part && ((
|
|
1949
|
+
if ("executableCode" in part && ((_l = part.executableCode) == null ? void 0 : _l.code)) {
|
|
1806
1950
|
const toolCallId = this.config.generateId();
|
|
1807
1951
|
lastCodeExecutionToolCallId = toolCallId;
|
|
1808
1952
|
content.push({
|
|
@@ -1820,7 +1964,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1820
1964
|
toolName: "code_execution",
|
|
1821
1965
|
result: {
|
|
1822
1966
|
outcome: part.codeExecutionResult.outcome,
|
|
1823
|
-
output: (
|
|
1967
|
+
output: (_m = part.codeExecutionResult.output) != null ? _m : ""
|
|
1824
1968
|
}
|
|
1825
1969
|
});
|
|
1826
1970
|
} else if ("text" in part && part.text != null) {
|
|
@@ -1844,9 +1988,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1844
1988
|
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1845
1989
|
content.push({
|
|
1846
1990
|
type: "tool-call",
|
|
1847
|
-
toolCallId: (
|
|
1991
|
+
toolCallId: (_n = part.functionCall.id) != null ? _n : this.config.generateId(),
|
|
1848
1992
|
toolName: part.functionCall.name,
|
|
1849
|
-
input: JSON.stringify((
|
|
1993
|
+
input: JSON.stringify((_o = part.functionCall.args) != null ? _o : {}),
|
|
1850
1994
|
providerMetadata: part.thoughtSignature ? {
|
|
1851
1995
|
[providerOptionsName]: {
|
|
1852
1996
|
thoughtSignature: part.thoughtSignature
|
|
@@ -1868,13 +2012,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1868
2012
|
} : void 0
|
|
1869
2013
|
});
|
|
1870
2014
|
} else if ("toolCall" in part && part.toolCall) {
|
|
1871
|
-
const toolCallId = (
|
|
2015
|
+
const toolCallId = (_p = part.toolCall.id) != null ? _p : this.config.generateId();
|
|
1872
2016
|
lastServerToolCallId = toolCallId;
|
|
1873
2017
|
content.push({
|
|
1874
2018
|
type: "tool-call",
|
|
1875
2019
|
toolCallId,
|
|
1876
2020
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1877
|
-
input: JSON.stringify((
|
|
2021
|
+
input: JSON.stringify((_q = part.toolCall.args) != null ? _q : {}),
|
|
1878
2022
|
providerExecuted: true,
|
|
1879
2023
|
dynamic: true,
|
|
1880
2024
|
providerMetadata: part.thoughtSignature ? {
|
|
@@ -1891,12 +2035,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1891
2035
|
}
|
|
1892
2036
|
});
|
|
1893
2037
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1894
|
-
const responseToolCallId = (
|
|
2038
|
+
const responseToolCallId = (_r = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _r : this.config.generateId();
|
|
1895
2039
|
content.push({
|
|
1896
2040
|
type: "tool-result",
|
|
1897
2041
|
toolCallId: responseToolCallId,
|
|
1898
2042
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1899
|
-
result: (
|
|
2043
|
+
result: (_s = part.toolResponse.response) != null ? _s : {},
|
|
1900
2044
|
providerMetadata: part.thoughtSignature ? {
|
|
1901
2045
|
[providerOptionsName]: {
|
|
1902
2046
|
thoughtSignature: part.thoughtSignature,
|
|
@@ -1913,10 +2057,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1913
2057
|
lastServerToolCallId = void 0;
|
|
1914
2058
|
}
|
|
1915
2059
|
}
|
|
1916
|
-
const sources = (
|
|
2060
|
+
const sources = (_t = extractSources({
|
|
1917
2061
|
groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
|
|
1918
2062
|
generateId: this.config.generateId
|
|
1919
|
-
})) != null ?
|
|
2063
|
+
})) != null ? _t : [];
|
|
1920
2064
|
for (const source of sources) {
|
|
1921
2065
|
content.push(source);
|
|
1922
2066
|
}
|
|
@@ -1936,19 +2080,21 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1936
2080
|
warnings,
|
|
1937
2081
|
providerMetadata: {
|
|
1938
2082
|
[providerOptionsName]: {
|
|
1939
|
-
promptFeedback: (
|
|
1940
|
-
groundingMetadata: (
|
|
1941
|
-
urlContextMetadata: (
|
|
1942
|
-
safetyRatings: (
|
|
2083
|
+
promptFeedback: (_u = response.promptFeedback) != null ? _u : null,
|
|
2084
|
+
groundingMetadata: (_v = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _v : null,
|
|
2085
|
+
urlContextMetadata: (_w = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _w : null,
|
|
2086
|
+
safetyRatings: (_x = candidate == null ? void 0 : candidate.safetyRatings) != null ? _x : null,
|
|
1943
2087
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1944
|
-
finishMessage: (
|
|
1945
|
-
serviceTier: (
|
|
2088
|
+
finishMessage: (_y = candidate == null ? void 0 : candidate.finishMessage) != null ? _y : null,
|
|
2089
|
+
serviceTier: (_z = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _z : null,
|
|
2090
|
+
...(candidate == null ? void 0 : candidate.continuationToken) != null ? { continuationToken: candidate.continuationToken } : {},
|
|
2091
|
+
...continuedUsageMetadata != null && firstPromptTokenCount != null ? { initialPromptTokenCount: firstPromptTokenCount } : {}
|
|
1946
2092
|
}
|
|
1947
2093
|
},
|
|
1948
2094
|
request: { body: args },
|
|
1949
2095
|
response: {
|
|
1950
2096
|
// TODO timestamp, model id
|
|
1951
|
-
id: (
|
|
2097
|
+
id: (_A = response.responseId) != null ? _A : void 0,
|
|
1952
2098
|
headers: responseHeaders,
|
|
1953
2099
|
body: rawResponse
|
|
1954
2100
|
}
|
|
@@ -1961,27 +2107,40 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1961
2107
|
options.headers,
|
|
1962
2108
|
extraHeaders
|
|
1963
2109
|
);
|
|
1964
|
-
const
|
|
2110
|
+
const streamGenerateContent = (body) => (0, import_provider_utils5.postJsonToApi)({
|
|
1965
2111
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1966
2112
|
this.modelId
|
|
1967
2113
|
)}:streamGenerateContent?alt=sse`,
|
|
1968
2114
|
headers,
|
|
1969
|
-
body
|
|
2115
|
+
body,
|
|
1970
2116
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1971
2117
|
successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(chunkSchema),
|
|
1972
2118
|
abortSignal: options.abortSignal,
|
|
1973
2119
|
fetch: this.config.fetch
|
|
1974
2120
|
});
|
|
2121
|
+
const { responseHeaders, value: firstResponse } = await streamGenerateContent(args);
|
|
2122
|
+
const response = continueGoogleStream({
|
|
2123
|
+
stream: firstResponse,
|
|
2124
|
+
getContinuationToken: (chunk) => {
|
|
2125
|
+
var _a, _b;
|
|
2126
|
+
const candidate = (_a = chunk.candidates) == null ? void 0 : _a[0];
|
|
2127
|
+
return (candidate == null ? void 0 : candidate.finishReason) === "CONTINUATION" ? (_b = candidate.continuationToken) != null ? _b : void 0 : void 0;
|
|
2128
|
+
},
|
|
2129
|
+
continueStream: async (continuationToken) => (await streamGenerateContent({ ...args, continuationToken })).value
|
|
2130
|
+
});
|
|
1975
2131
|
let finishReason = {
|
|
1976
2132
|
unified: "other",
|
|
1977
2133
|
raw: void 0
|
|
1978
2134
|
};
|
|
1979
2135
|
let usage = void 0;
|
|
2136
|
+
let continuedUsage = void 0;
|
|
2137
|
+
let initialPromptTokenCount = void 0;
|
|
1980
2138
|
let promptFeedback = null;
|
|
1981
2139
|
let lastGroundingMetadata = null;
|
|
1982
2140
|
let lastUrlContextMetadata = null;
|
|
1983
2141
|
let lastSafetyRatings = null;
|
|
1984
2142
|
let lastFinishMessage = null;
|
|
2143
|
+
let lastContinuationToken = null;
|
|
1985
2144
|
let confirmedPromptBlockReason;
|
|
1986
2145
|
const generateId2 = this.config.generateId;
|
|
1987
2146
|
let hasToolCalls = false;
|
|
@@ -2072,6 +2231,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2072
2231
|
if (candidate.finishMessage != null) {
|
|
2073
2232
|
lastFinishMessage = candidate.finishMessage;
|
|
2074
2233
|
}
|
|
2234
|
+
if (candidate.continuationToken != null) {
|
|
2235
|
+
lastContinuationToken = candidate.continuationToken;
|
|
2236
|
+
}
|
|
2075
2237
|
}
|
|
2076
2238
|
if (confirmedPromptBlockReason != null || candidate == null) {
|
|
2077
2239
|
return;
|
|
@@ -2356,6 +2518,16 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2356
2518
|
}
|
|
2357
2519
|
}
|
|
2358
2520
|
}
|
|
2521
|
+
if (candidate.finishReason === "CONTINUATION") {
|
|
2522
|
+
if (continuedUsage == null) {
|
|
2523
|
+
initialPromptTokenCount = usage == null ? void 0 : usage.promptTokenCount;
|
|
2524
|
+
}
|
|
2525
|
+
continuedUsage = addGoogleGenerativeAIUsageMetadata(
|
|
2526
|
+
continuedUsage,
|
|
2527
|
+
usage
|
|
2528
|
+
);
|
|
2529
|
+
usage = void 0;
|
|
2530
|
+
}
|
|
2359
2531
|
if (candidate.finishReason != null) {
|
|
2360
2532
|
finishReason = {
|
|
2361
2533
|
unified: mapGoogleGenerativeAIFinishReason({
|
|
@@ -2368,6 +2540,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2368
2540
|
},
|
|
2369
2541
|
flush(controller) {
|
|
2370
2542
|
var _a;
|
|
2543
|
+
usage = addGoogleGenerativeAIUsageMetadata(continuedUsage, usage);
|
|
2371
2544
|
if (currentTextBlockId !== null) {
|
|
2372
2545
|
controller.enqueue({
|
|
2373
2546
|
type: "text-end",
|
|
@@ -2392,7 +2565,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2392
2565
|
safetyRatings: lastSafetyRatings,
|
|
2393
2566
|
usageMetadata: usage != null ? usage : null,
|
|
2394
2567
|
finishMessage: lastFinishMessage,
|
|
2395
|
-
serviceTier: (_a = usage == null ? void 0 : usage.serviceTier) != null ? _a : null
|
|
2568
|
+
serviceTier: (_a = usage == null ? void 0 : usage.serviceTier) != null ? _a : null,
|
|
2569
|
+
// Only surface the token when the response stopped early
|
|
2570
|
+
// (budget used up, or continuing failed), not for the
|
|
2571
|
+
// checkpoint tokens of a stream that finished normally.
|
|
2572
|
+
...lastContinuationToken != null && (finishReason.raw === "MAX_TOKENS" || finishReason.raw === "CONTINUATION") ? { continuationToken: lastContinuationToken } : {},
|
|
2573
|
+
...initialPromptTokenCount != null ? { initialPromptTokenCount } : {}
|
|
2396
2574
|
}
|
|
2397
2575
|
}
|
|
2398
2576
|
});
|
|
@@ -2516,7 +2694,15 @@ var getGroundingMetadataSchema = () => import_v43.z.object({
|
|
|
2516
2694
|
uri: import_v43.z.string().nullish(),
|
|
2517
2695
|
title: import_v43.z.string().nullish(),
|
|
2518
2696
|
text: import_v43.z.string().nullish(),
|
|
2519
|
-
fileSearchStore: import_v43.z.string().nullish()
|
|
2697
|
+
fileSearchStore: import_v43.z.string().nullish(),
|
|
2698
|
+
customMetadata: import_v43.z.array(
|
|
2699
|
+
import_v43.z.object({
|
|
2700
|
+
key: import_v43.z.string(),
|
|
2701
|
+
stringValue: import_v43.z.string().nullish(),
|
|
2702
|
+
numericValue: import_v43.z.number().nullish(),
|
|
2703
|
+
stringListValue: import_v43.z.object({ values: import_v43.z.array(import_v43.z.string()).nullish() }).nullish()
|
|
2704
|
+
})
|
|
2705
|
+
).nullish()
|
|
2520
2706
|
}).nullish(),
|
|
2521
2707
|
maps: import_v43.z.object({
|
|
2522
2708
|
uri: import_v43.z.string().nullish(),
|
|
@@ -2656,6 +2842,7 @@ var responseSchema = (0, import_provider_utils5.lazySchema)(
|
|
|
2656
2842
|
content: getContentSchema().nullish().or(import_v43.z.object({}).strict()),
|
|
2657
2843
|
finishReason: import_v43.z.string().nullish(),
|
|
2658
2844
|
finishMessage: import_v43.z.string().nullish(),
|
|
2845
|
+
continuationToken: import_v43.z.string().nullish(),
|
|
2659
2846
|
safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
|
|
2660
2847
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2661
2848
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
@@ -2678,6 +2865,7 @@ var chunkSchema = (0, import_provider_utils5.lazySchema)(
|
|
|
2678
2865
|
content: getContentSchema().nullish(),
|
|
2679
2866
|
finishReason: import_v43.z.string().nullish(),
|
|
2680
2867
|
finishMessage: import_v43.z.string().nullish(),
|
|
2868
|
+
continuationToken: import_v43.z.string().nullish(),
|
|
2681
2869
|
safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
|
|
2682
2870
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2683
2871
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
@@ -5567,7 +5755,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5567
5755
|
}
|
|
5568
5756
|
async doGenerate(options) {
|
|
5569
5757
|
var _a, _b, _c, _d, _e, _f;
|
|
5570
|
-
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
5758
|
+
const { args, warnings, isAgent, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
5571
5759
|
const url = `${this.config.baseURL}/interactions`;
|
|
5572
5760
|
const mergedHeaders = (0, import_provider_utils19.combineHeaders)(
|
|
5573
5761
|
INTERACTIONS_API_REVISION_HEADER,
|
|
@@ -5590,7 +5778,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5590
5778
|
value: response,
|
|
5591
5779
|
rawValue: rawResponse
|
|
5592
5780
|
} = postResult;
|
|
5593
|
-
if (isAgent && !isTerminalStatus(response.status)) {
|
|
5781
|
+
if ((isAgent || isBackground) && !isTerminalStatus(response.status)) {
|
|
5594
5782
|
const polled = await pollGoogleInteractionUntilTerminal({
|
|
5595
5783
|
baseURL: this.config.baseURL,
|
|
5596
5784
|
interactionId: response.id,
|