@ai-sdk/google 4.0.0-beta.47 → 4.0.0-beta.49
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 +25 -0
- package/dist/index.d.ts +10 -10
- package/dist/index.js +306 -254
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +214 -178
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +4 -4
- package/package.json +4 -4
- package/src/convert-google-usage.ts +1 -1
- package/src/convert-json-schema-to-openapi-schema.ts +1 -1
- package/src/convert-to-google-messages.ts +153 -94
- package/src/google-embedding-model.ts +4 -5
- package/src/google-error.ts +1 -1
- package/src/google-files.ts +3 -6
- package/src/google-image-model-options.ts +23 -0
- package/src/google-image-model.ts +27 -35
- package/src/{google-options.ts → google-language-model-options.ts} +5 -1
- package/src/google-language-model.ts +118 -121
- package/src/google-prepare-tools.ts +3 -3
- package/src/google-prompt.ts +2 -2
- package/src/google-provider.ts +6 -6
- package/src/google-video-model-options.ts +43 -0
- package/src/google-video-model.ts +6 -45
- package/src/index.ts +4 -4
- package/src/internal/index.ts +1 -1
- package/src/map-google-finish-reason.ts +1 -1
- package/src/{google-embedding-options.ts → google-embedding-model-options.ts} +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
LanguageModelV4,
|
|
3
3
|
LanguageModelV4CallOptions,
|
|
4
4
|
LanguageModelV4Content,
|
|
@@ -15,40 +15,44 @@ import {
|
|
|
15
15
|
combineHeaders,
|
|
16
16
|
createEventSourceResponseHandler,
|
|
17
17
|
createJsonResponseHandler,
|
|
18
|
-
FetchFunction,
|
|
19
18
|
generateId,
|
|
20
|
-
InferSchema,
|
|
21
19
|
isCustomReasoning,
|
|
22
20
|
lazySchema,
|
|
23
21
|
mapReasoningToProviderBudget,
|
|
24
22
|
mapReasoningToProviderEffort,
|
|
25
23
|
parseProviderOptions,
|
|
26
|
-
ParseResult,
|
|
27
24
|
postJsonToApi,
|
|
28
|
-
Resolvable,
|
|
29
25
|
resolve,
|
|
30
26
|
serializeModelOptions,
|
|
31
27
|
WORKFLOW_SERIALIZE,
|
|
32
28
|
WORKFLOW_DESERIALIZE,
|
|
33
29
|
zodSchema,
|
|
30
|
+
type FetchFunction,
|
|
31
|
+
type InferSchema,
|
|
32
|
+
type ParseResult,
|
|
33
|
+
type Resolvable,
|
|
34
34
|
} from '@ai-sdk/provider-utils';
|
|
35
35
|
import { z } from 'zod/v4';
|
|
36
36
|
import {
|
|
37
37
|
convertGoogleUsage,
|
|
38
|
-
GoogleUsageMetadata,
|
|
38
|
+
type GoogleUsageMetadata,
|
|
39
39
|
} from './convert-google-usage';
|
|
40
40
|
import { convertJSONSchemaToOpenAPISchema } from './convert-json-schema-to-openapi-schema';
|
|
41
41
|
import { convertToGoogleMessages } from './convert-to-google-messages';
|
|
42
42
|
import { getModelPath } from './get-model-path';
|
|
43
43
|
import { googleFailedResponseHandler } from './google-error';
|
|
44
44
|
import {
|
|
45
|
-
GoogleModelId,
|
|
46
45
|
googleLanguageModelOptions,
|
|
47
46
|
VertexServiceTierMap,
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
type GoogleLanguageModelOptions,
|
|
48
|
+
type GoogleModelId,
|
|
49
|
+
} from './google-language-model-options';
|
|
50
|
+
import type { GoogleProviderMetadata } from './google-prompt';
|
|
50
51
|
import { prepareTools } from './google-prepare-tools';
|
|
51
|
-
import {
|
|
52
|
+
import {
|
|
53
|
+
GoogleJSONAccumulator,
|
|
54
|
+
type PartialArg,
|
|
55
|
+
} from './google-json-accumulator';
|
|
52
56
|
import { mapGoogleFinishReason } from './map-google-finish-reason';
|
|
53
57
|
|
|
54
58
|
type GoogleConfig = {
|
|
@@ -121,16 +125,28 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
121
125
|
) {
|
|
122
126
|
const warnings: SharedV4Warning[] = [];
|
|
123
127
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
// Names to look up in providerOptions and to write into providerMetadata.
|
|
129
|
+
// For the Vertex provider we read both the new `googleVertex` key and the
|
|
130
|
+
// legacy `vertex` key (new takes precedence) and write under both for
|
|
131
|
+
// backward compatibility. For other Google providers we use just `google`.
|
|
132
|
+
const providerOptionsNames: readonly string[] =
|
|
133
|
+
this.config.provider.includes('vertex')
|
|
134
|
+
? (['googleVertex', 'vertex'] as const)
|
|
135
|
+
: (['google'] as const);
|
|
136
|
+
|
|
137
|
+
let googleOptions: GoogleLanguageModelOptions | undefined;
|
|
138
|
+
for (const name of providerOptionsNames) {
|
|
139
|
+
googleOptions = await parseProviderOptions({
|
|
140
|
+
provider: name,
|
|
141
|
+
providerOptions,
|
|
142
|
+
schema: googleLanguageModelOptions,
|
|
143
|
+
});
|
|
144
|
+
if (googleOptions != null) break;
|
|
145
|
+
}
|
|
132
146
|
|
|
133
|
-
|
|
147
|
+
// Cross-namespace fallback: a Vertex provider may receive options under
|
|
148
|
+
// the `google` key (e.g. via the AI Gateway).
|
|
149
|
+
if (googleOptions == null && !providerOptionsNames.includes('google')) {
|
|
134
150
|
googleOptions = await parseProviderOptions({
|
|
135
151
|
provider: 'google',
|
|
136
152
|
providerOptions,
|
|
@@ -178,7 +194,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
178
194
|
|
|
179
195
|
const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
|
|
180
196
|
isGemmaModel,
|
|
181
|
-
|
|
197
|
+
providerOptionsNames,
|
|
182
198
|
supportsFunctionResponseParts,
|
|
183
199
|
});
|
|
184
200
|
|
|
@@ -275,14 +291,19 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
275
291
|
serviceTier: sanitizedServiceTier,
|
|
276
292
|
},
|
|
277
293
|
warnings: [...warnings, ...toolWarnings],
|
|
278
|
-
|
|
294
|
+
providerOptionsNames,
|
|
279
295
|
};
|
|
280
296
|
}
|
|
281
297
|
|
|
282
298
|
async doGenerate(
|
|
283
299
|
options: LanguageModelV4CallOptions,
|
|
284
300
|
): Promise<LanguageModelV4GenerateResult> {
|
|
285
|
-
const { args, warnings,
|
|
301
|
+
const { args, warnings, providerOptionsNames } =
|
|
302
|
+
await this.getArgs(options);
|
|
303
|
+
const wrapProviderMetadata = (payload: Record<string, unknown>) =>
|
|
304
|
+
Object.fromEntries(
|
|
305
|
+
providerOptionsNames.map(name => [name, payload]),
|
|
306
|
+
) as SharedV4ProviderMetadata;
|
|
286
307
|
|
|
287
308
|
const mergedHeaders = combineHeaders(
|
|
288
309
|
this.config.headers ? await resolve(this.config.headers) : undefined,
|
|
@@ -346,11 +367,9 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
346
367
|
lastCodeExecutionToolCallId = undefined;
|
|
347
368
|
} else if ('text' in part && part.text != null) {
|
|
348
369
|
const thoughtSignatureMetadata = part.thoughtSignature
|
|
349
|
-
? {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
},
|
|
353
|
-
}
|
|
370
|
+
? wrapProviderMetadata({
|
|
371
|
+
thoughtSignature: part.thoughtSignature,
|
|
372
|
+
})
|
|
354
373
|
: undefined;
|
|
355
374
|
|
|
356
375
|
if (part.text.length === 0) {
|
|
@@ -376,11 +395,9 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
376
395
|
toolName: part.functionCall.name,
|
|
377
396
|
input: JSON.stringify(part.functionCall.args),
|
|
378
397
|
providerMetadata: part.thoughtSignature
|
|
379
|
-
? {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
},
|
|
383
|
-
}
|
|
398
|
+
? wrapProviderMetadata({
|
|
399
|
+
thoughtSignature: part.thoughtSignature,
|
|
400
|
+
})
|
|
384
401
|
: undefined,
|
|
385
402
|
});
|
|
386
403
|
} else if ('inlineData' in part) {
|
|
@@ -388,14 +405,12 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
388
405
|
const hasThoughtSignature = !!part.thoughtSignature;
|
|
389
406
|
content.push({
|
|
390
407
|
type: hasThought ? 'reasoning-file' : 'file',
|
|
391
|
-
data: part.inlineData.data,
|
|
408
|
+
data: { type: 'data', data: part.inlineData.data },
|
|
392
409
|
mediaType: part.inlineData.mimeType,
|
|
393
410
|
providerMetadata: hasThoughtSignature
|
|
394
|
-
? {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
},
|
|
398
|
-
}
|
|
411
|
+
? wrapProviderMetadata({
|
|
412
|
+
thoughtSignature: part.thoughtSignature,
|
|
413
|
+
})
|
|
399
414
|
: undefined,
|
|
400
415
|
});
|
|
401
416
|
} else if ('toolCall' in part && part.toolCall) {
|
|
@@ -409,19 +424,15 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
409
424
|
providerExecuted: true,
|
|
410
425
|
dynamic: true,
|
|
411
426
|
providerMetadata: part.thoughtSignature
|
|
412
|
-
? {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
serverToolCallId: toolCallId,
|
|
422
|
-
serverToolType: part.toolCall.toolType,
|
|
423
|
-
},
|
|
424
|
-
},
|
|
427
|
+
? wrapProviderMetadata({
|
|
428
|
+
thoughtSignature: part.thoughtSignature,
|
|
429
|
+
serverToolCallId: toolCallId,
|
|
430
|
+
serverToolType: part.toolCall.toolType,
|
|
431
|
+
})
|
|
432
|
+
: wrapProviderMetadata({
|
|
433
|
+
serverToolCallId: toolCallId,
|
|
434
|
+
serverToolType: part.toolCall.toolType,
|
|
435
|
+
}),
|
|
425
436
|
});
|
|
426
437
|
} else if ('toolResponse' in part && part.toolResponse) {
|
|
427
438
|
const responseToolCallId =
|
|
@@ -434,19 +445,15 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
434
445
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
435
446
|
result: (part.toolResponse.response ?? {}) as JSONObject,
|
|
436
447
|
providerMetadata: part.thoughtSignature
|
|
437
|
-
? {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
serverToolCallId: responseToolCallId,
|
|
447
|
-
serverToolType: part.toolResponse.toolType,
|
|
448
|
-
},
|
|
449
|
-
},
|
|
448
|
+
? wrapProviderMetadata({
|
|
449
|
+
thoughtSignature: part.thoughtSignature,
|
|
450
|
+
serverToolCallId: responseToolCallId,
|
|
451
|
+
serverToolType: part.toolResponse.toolType,
|
|
452
|
+
})
|
|
453
|
+
: wrapProviderMetadata({
|
|
454
|
+
serverToolCallId: responseToolCallId,
|
|
455
|
+
serverToolType: part.toolResponse.toolType,
|
|
456
|
+
}),
|
|
450
457
|
});
|
|
451
458
|
lastServerToolCallId = undefined;
|
|
452
459
|
}
|
|
@@ -475,17 +482,15 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
475
482
|
},
|
|
476
483
|
usage: convertGoogleUsage(usageMetadata),
|
|
477
484
|
warnings,
|
|
478
|
-
providerMetadata: {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
} satisfies GoogleProviderMetadata,
|
|
488
|
-
},
|
|
485
|
+
providerMetadata: wrapProviderMetadata({
|
|
486
|
+
promptFeedback: response.promptFeedback ?? null,
|
|
487
|
+
groundingMetadata: candidate.groundingMetadata ?? null,
|
|
488
|
+
urlContextMetadata: candidate.urlContextMetadata ?? null,
|
|
489
|
+
safetyRatings: candidate.safetyRatings ?? null,
|
|
490
|
+
usageMetadata: usageMetadata ?? null,
|
|
491
|
+
finishMessage: candidate.finishMessage ?? null,
|
|
492
|
+
serviceTier: response.serviceTier ?? null,
|
|
493
|
+
} satisfies GoogleProviderMetadata),
|
|
489
494
|
request: { body: args },
|
|
490
495
|
response: {
|
|
491
496
|
// TODO timestamp, model id, id
|
|
@@ -498,10 +503,14 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
498
503
|
async doStream(
|
|
499
504
|
options: LanguageModelV4CallOptions,
|
|
500
505
|
): Promise<LanguageModelV4StreamResult> {
|
|
501
|
-
const { args, warnings,
|
|
506
|
+
const { args, warnings, providerOptionsNames } = await this.getArgs(
|
|
502
507
|
options,
|
|
503
508
|
{ isStreaming: true },
|
|
504
509
|
);
|
|
510
|
+
const wrapProviderMetadata = (payload: Record<string, unknown>) =>
|
|
511
|
+
Object.fromEntries(
|
|
512
|
+
providerOptionsNames.map(name => [name, payload]),
|
|
513
|
+
) as SharedV4ProviderMetadata;
|
|
505
514
|
|
|
506
515
|
const headers = combineHeaders(
|
|
507
516
|
this.config.headers ? await resolve(this.config.headers) : undefined,
|
|
@@ -654,11 +663,9 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
654
663
|
}
|
|
655
664
|
} else if ('text' in part && part.text != null) {
|
|
656
665
|
const thoughtSignatureMetadata = part.thoughtSignature
|
|
657
|
-
? {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
},
|
|
661
|
-
}
|
|
666
|
+
? wrapProviderMetadata({
|
|
667
|
+
thoughtSignature: part.thoughtSignature,
|
|
668
|
+
})
|
|
662
669
|
: undefined;
|
|
663
670
|
|
|
664
671
|
if (part.text.length === 0) {
|
|
@@ -745,30 +752,26 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
745
752
|
const hasThought = part.thought === true;
|
|
746
753
|
const hasThoughtSignature = !!part.thoughtSignature;
|
|
747
754
|
const fileMeta = hasThoughtSignature
|
|
748
|
-
? {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
},
|
|
752
|
-
}
|
|
755
|
+
? wrapProviderMetadata({
|
|
756
|
+
thoughtSignature: part.thoughtSignature,
|
|
757
|
+
})
|
|
753
758
|
: undefined;
|
|
754
759
|
controller.enqueue({
|
|
755
760
|
type: hasThought ? 'reasoning-file' : 'file',
|
|
756
761
|
mediaType: part.inlineData.mimeType,
|
|
757
|
-
data: part.inlineData.data,
|
|
762
|
+
data: { type: 'data', data: part.inlineData.data },
|
|
758
763
|
providerMetadata: fileMeta,
|
|
759
764
|
});
|
|
760
765
|
} else if ('toolCall' in part && part.toolCall) {
|
|
761
766
|
const toolCallId = part.toolCall.id ?? generateId();
|
|
762
767
|
lastServerToolCallId = toolCallId;
|
|
763
|
-
const serverMeta = {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
},
|
|
771
|
-
};
|
|
768
|
+
const serverMeta = wrapProviderMetadata({
|
|
769
|
+
...(part.thoughtSignature
|
|
770
|
+
? { thoughtSignature: part.thoughtSignature }
|
|
771
|
+
: {}),
|
|
772
|
+
serverToolCallId: toolCallId,
|
|
773
|
+
serverToolType: part.toolCall.toolType,
|
|
774
|
+
});
|
|
772
775
|
|
|
773
776
|
controller.enqueue({
|
|
774
777
|
type: 'tool-call',
|
|
@@ -784,15 +787,13 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
784
787
|
lastServerToolCallId ??
|
|
785
788
|
part.toolResponse.id ??
|
|
786
789
|
generateId();
|
|
787
|
-
const serverMeta = {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
},
|
|
795
|
-
};
|
|
790
|
+
const serverMeta = wrapProviderMetadata({
|
|
791
|
+
...(part.thoughtSignature
|
|
792
|
+
? { thoughtSignature: part.thoughtSignature }
|
|
793
|
+
: {}),
|
|
794
|
+
serverToolCallId: responseToolCallId,
|
|
795
|
+
serverToolType: part.toolResponse.toolType,
|
|
796
|
+
});
|
|
796
797
|
|
|
797
798
|
controller.enqueue({
|
|
798
799
|
type: 'tool-result',
|
|
@@ -810,11 +811,9 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
810
811
|
if (!('functionCall' in part)) continue;
|
|
811
812
|
|
|
812
813
|
const providerMeta = part.thoughtSignature
|
|
813
|
-
? {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
},
|
|
817
|
-
}
|
|
814
|
+
? wrapProviderMetadata({
|
|
815
|
+
thoughtSignature: part.thoughtSignature,
|
|
816
|
+
})
|
|
818
817
|
: undefined;
|
|
819
818
|
|
|
820
819
|
const isStreamingChunk =
|
|
@@ -967,17 +966,15 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
967
966
|
raw: candidate.finishReason,
|
|
968
967
|
};
|
|
969
968
|
|
|
970
|
-
providerMetadata = {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
} satisfies GoogleProviderMetadata,
|
|
980
|
-
};
|
|
969
|
+
providerMetadata = wrapProviderMetadata({
|
|
970
|
+
promptFeedback: value.promptFeedback ?? null,
|
|
971
|
+
groundingMetadata: lastGroundingMetadata,
|
|
972
|
+
urlContextMetadata: lastUrlContextMetadata,
|
|
973
|
+
safetyRatings: candidate.safetyRatings ?? null,
|
|
974
|
+
usageMetadata: usageMetadata ?? null,
|
|
975
|
+
finishMessage: candidate.finishMessage ?? null,
|
|
976
|
+
serviceTier,
|
|
977
|
+
} satisfies GoogleProviderMetadata);
|
|
981
978
|
}
|
|
982
979
|
},
|
|
983
980
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LanguageModelV4CallOptions,
|
|
3
|
-
SharedV4Warning,
|
|
4
2
|
UnsupportedFunctionalityError,
|
|
3
|
+
type LanguageModelV4CallOptions,
|
|
4
|
+
type SharedV4Warning,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
6
|
import { convertJSONSchemaToOpenAPISchema } from './convert-json-schema-to-openapi-schema';
|
|
7
|
-
import { GoogleModelId } from './google-options';
|
|
7
|
+
import type { GoogleModelId } from './google-language-model-options';
|
|
8
8
|
|
|
9
9
|
export function prepareTools({
|
|
10
10
|
tools,
|
package/src/google-prompt.ts
CHANGED
package/src/google-provider.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
EmbeddingModelV4,
|
|
3
3
|
Experimental_VideoModelV4,
|
|
4
4
|
FilesV4,
|
|
@@ -7,27 +7,27 @@ import {
|
|
|
7
7
|
ProviderV4,
|
|
8
8
|
} from '@ai-sdk/provider';
|
|
9
9
|
import {
|
|
10
|
-
FetchFunction,
|
|
11
10
|
generateId,
|
|
12
11
|
loadApiKey,
|
|
13
12
|
withoutTrailingSlash,
|
|
14
13
|
withUserAgentSuffix,
|
|
14
|
+
type FetchFunction,
|
|
15
15
|
} from '@ai-sdk/provider-utils';
|
|
16
16
|
import { VERSION } from './version';
|
|
17
17
|
import { GoogleEmbeddingModel } from './google-embedding-model';
|
|
18
|
-
import { GoogleEmbeddingModelId } from './google-embedding-options';
|
|
18
|
+
import type { GoogleEmbeddingModelId } from './google-embedding-model-options';
|
|
19
19
|
import { GoogleLanguageModel } from './google-language-model';
|
|
20
|
-
import { GoogleModelId } from './google-options';
|
|
20
|
+
import type { GoogleModelId } from './google-language-model-options';
|
|
21
21
|
import { googleTools } from './google-tools';
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import type {
|
|
24
24
|
GoogleImageSettings,
|
|
25
25
|
GoogleImageModelId,
|
|
26
26
|
} from './google-image-settings';
|
|
27
27
|
import { GoogleImageModel } from './google-image-model';
|
|
28
28
|
import { GoogleFiles } from './google-files';
|
|
29
29
|
import { GoogleVideoModel } from './google-video-model';
|
|
30
|
-
import { GoogleVideoModelId } from './google-video-settings';
|
|
30
|
+
import type { GoogleVideoModelId } from './google-video-settings';
|
|
31
31
|
|
|
32
32
|
export interface GoogleProvider extends ProviderV4 {
|
|
33
33
|
(modelId: GoogleModelId): LanguageModelV4;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
|
|
4
|
+
export type GoogleVideoModelOptions = {
|
|
5
|
+
// Polling configuration
|
|
6
|
+
pollIntervalMs?: number | null;
|
|
7
|
+
pollTimeoutMs?: number | null;
|
|
8
|
+
|
|
9
|
+
// Video generation options
|
|
10
|
+
personGeneration?: 'dont_allow' | 'allow_adult' | 'allow_all' | null;
|
|
11
|
+
negativePrompt?: string | null;
|
|
12
|
+
|
|
13
|
+
// Reference images (for style/asset reference)
|
|
14
|
+
referenceImages?: Array<{
|
|
15
|
+
bytesBase64Encoded?: string;
|
|
16
|
+
gcsUri?: string;
|
|
17
|
+
}> | null;
|
|
18
|
+
|
|
19
|
+
[key: string]: unknown; // For passthrough
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const googleVideoModelOptionsSchema = lazySchema(() =>
|
|
23
|
+
zodSchema(
|
|
24
|
+
z
|
|
25
|
+
.object({
|
|
26
|
+
pollIntervalMs: z.number().positive().nullish(),
|
|
27
|
+
pollTimeoutMs: z.number().positive().nullish(),
|
|
28
|
+
personGeneration: z
|
|
29
|
+
.enum(['dont_allow', 'allow_adult', 'allow_all'])
|
|
30
|
+
.nullish(),
|
|
31
|
+
negativePrompt: z.string().nullish(),
|
|
32
|
+
referenceImages: z
|
|
33
|
+
.array(
|
|
34
|
+
z.object({
|
|
35
|
+
bytesBase64Encoded: z.string().nullish(),
|
|
36
|
+
gcsUri: z.string().nullish(),
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
.nullish(),
|
|
40
|
+
})
|
|
41
|
+
.passthrough(),
|
|
42
|
+
),
|
|
43
|
+
);
|
|
@@ -8,37 +8,21 @@ import {
|
|
|
8
8
|
convertUint8ArrayToBase64,
|
|
9
9
|
createJsonResponseHandler,
|
|
10
10
|
delay,
|
|
11
|
-
type FetchFunction,
|
|
12
11
|
getFromApi,
|
|
13
|
-
lazySchema,
|
|
14
12
|
parseProviderOptions,
|
|
15
13
|
postJsonToApi,
|
|
16
|
-
type Resolvable,
|
|
17
14
|
resolve,
|
|
18
|
-
|
|
15
|
+
type FetchFunction,
|
|
16
|
+
type Resolvable,
|
|
19
17
|
} from '@ai-sdk/provider-utils';
|
|
20
18
|
import { z } from 'zod/v4';
|
|
21
19
|
import { googleFailedResponseHandler } from './google-error';
|
|
20
|
+
import {
|
|
21
|
+
googleVideoModelOptionsSchema,
|
|
22
|
+
type GoogleVideoModelOptions,
|
|
23
|
+
} from './google-video-model-options';
|
|
22
24
|
import type { GoogleVideoModelId } from './google-video-settings';
|
|
23
25
|
|
|
24
|
-
export type GoogleVideoModelOptions = {
|
|
25
|
-
// Polling configuration
|
|
26
|
-
pollIntervalMs?: number | null;
|
|
27
|
-
pollTimeoutMs?: number | null;
|
|
28
|
-
|
|
29
|
-
// Video generation options
|
|
30
|
-
personGeneration?: 'dont_allow' | 'allow_adult' | 'allow_all' | null;
|
|
31
|
-
negativePrompt?: string | null;
|
|
32
|
-
|
|
33
|
-
// Reference images (for style/asset reference)
|
|
34
|
-
referenceImages?: Array<{
|
|
35
|
-
bytesBase64Encoded?: string;
|
|
36
|
-
gcsUri?: string;
|
|
37
|
-
}> | null;
|
|
38
|
-
|
|
39
|
-
[key: string]: unknown; // For passthrough
|
|
40
|
-
};
|
|
41
|
-
|
|
42
26
|
interface GoogleVideoModelConfig {
|
|
43
27
|
provider: string;
|
|
44
28
|
baseURL: string;
|
|
@@ -349,26 +333,3 @@ const googleOperationSchema = z.object({
|
|
|
349
333
|
})
|
|
350
334
|
.nullish(),
|
|
351
335
|
});
|
|
352
|
-
|
|
353
|
-
const googleVideoModelOptionsSchema = lazySchema(() =>
|
|
354
|
-
zodSchema(
|
|
355
|
-
z
|
|
356
|
-
.object({
|
|
357
|
-
pollIntervalMs: z.number().positive().nullish(),
|
|
358
|
-
pollTimeoutMs: z.number().positive().nullish(),
|
|
359
|
-
personGeneration: z
|
|
360
|
-
.enum(['dont_allow', 'allow_adult', 'allow_all'])
|
|
361
|
-
.nullish(),
|
|
362
|
-
negativePrompt: z.string().nullish(),
|
|
363
|
-
referenceImages: z
|
|
364
|
-
.array(
|
|
365
|
-
z.object({
|
|
366
|
-
bytesBase64Encoded: z.string().nullish(),
|
|
367
|
-
gcsUri: z.string().nullish(),
|
|
368
|
-
}),
|
|
369
|
-
)
|
|
370
|
-
.nullish(),
|
|
371
|
-
})
|
|
372
|
-
.passthrough(),
|
|
373
|
-
),
|
|
374
|
-
);
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type {
|
|
|
3
3
|
GoogleLanguageModelOptions,
|
|
4
4
|
/** @deprecated Use `GoogleLanguageModelOptions` instead. */
|
|
5
5
|
GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions,
|
|
6
|
-
} from './google-options';
|
|
6
|
+
} from './google-language-model-options';
|
|
7
7
|
export type {
|
|
8
8
|
GoogleProviderMetadata,
|
|
9
9
|
/** @deprecated Use `GoogleProviderMetadata` instead. */
|
|
@@ -13,17 +13,17 @@ export type {
|
|
|
13
13
|
GoogleImageModelOptions,
|
|
14
14
|
/** @deprecated Use `GoogleImageModelOptions` instead. */
|
|
15
15
|
GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions,
|
|
16
|
-
} from './google-image-model';
|
|
16
|
+
} from './google-image-model-options';
|
|
17
17
|
export type {
|
|
18
18
|
GoogleEmbeddingModelOptions,
|
|
19
19
|
/** @deprecated Use `GoogleEmbeddingModelOptions` instead. */
|
|
20
20
|
GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions,
|
|
21
|
-
} from './google-embedding-options';
|
|
21
|
+
} from './google-embedding-model-options';
|
|
22
22
|
export type {
|
|
23
23
|
GoogleVideoModelOptions,
|
|
24
24
|
/** @deprecated Use `GoogleVideoModelOptions` instead. */
|
|
25
25
|
GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions,
|
|
26
|
-
} from './google-video-model';
|
|
26
|
+
} from './google-video-model-options';
|
|
27
27
|
export type {
|
|
28
28
|
GoogleVideoModelId,
|
|
29
29
|
/** @deprecated Use `GoogleVideoModelId` instead. */
|
package/src/internal/index.ts
CHANGED