@ai-sdk/google 4.0.0-beta.44 → 4.0.0-beta.46
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/README.md +4 -4
- package/dist/index.d.ts +40 -40
- package/dist/index.js +102 -108
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +16 -16
- package/dist/internal/index.js +62 -62
- package/dist/internal/index.js.map +1 -1
- package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +36 -36
- package/package.json +7 -6
- package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +6 -6
- package/src/{convert-to-google-generative-ai-messages.ts → convert-to-google-messages.ts} +15 -15
- package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +10 -16
- package/src/{google-generative-ai-embedding-options.ts → google-embedding-options.ts} +1 -1
- package/src/{google-generative-ai-files.ts → google-files.ts} +3 -3
- package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +16 -20
- package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
- package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +29 -34
- package/src/{google-generative-ai-options.ts → google-options.ts} +2 -2
- package/src/google-prepare-tools.ts +9 -5
- package/src/google-prompt.ts +82 -0
- package/src/google-provider.ts +42 -46
- package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +5 -5
- package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +1 -1
- package/src/index.ts +28 -10
- package/src/internal/index.ts +2 -2
- package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +1 -1
- package/src/tool/code-execution.ts +2 -2
- package/src/tool/enterprise-web-search.ts +9 -3
- package/src/tool/file-search.ts +5 -7
- package/src/tool/google-maps.ts +3 -2
- package/src/tool/google-search.ts +10 -11
- package/src/tool/url-context.ts +4 -2
- package/src/tool/vertex-rag-store.ts +9 -6
- package/src/google-generative-ai-prompt.ts +0 -82
package/dist/index.js
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.0-beta.
|
|
10
|
+
var VERSION = true ? "4.0.0-beta.46" : "0.0.0-test";
|
|
11
11
|
|
|
12
|
-
// src/google-
|
|
12
|
+
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
14
14
|
TooManyEmbeddingValuesForCallError
|
|
15
15
|
} from "@ai-sdk/provider";
|
|
@@ -50,7 +50,7 @@ var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
50
50
|
errorToMessage: (data) => data.error.message
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
// src/google-
|
|
53
|
+
// src/google-embedding-options.ts
|
|
54
54
|
import {
|
|
55
55
|
lazySchema as lazySchema2,
|
|
56
56
|
zodSchema as zodSchema2
|
|
@@ -109,8 +109,8 @@ var googleEmbeddingModelOptions = lazySchema2(
|
|
|
109
109
|
)
|
|
110
110
|
);
|
|
111
111
|
|
|
112
|
-
// src/google-
|
|
113
|
-
var
|
|
112
|
+
// src/google-embedding-model.ts
|
|
113
|
+
var GoogleEmbeddingModel = class _GoogleEmbeddingModel {
|
|
114
114
|
constructor(modelId, config) {
|
|
115
115
|
this.specificationVersion = "v4";
|
|
116
116
|
this.maxEmbeddingsPerCall = 2048;
|
|
@@ -125,10 +125,7 @@ var GoogleGenerativeAIEmbeddingModel = class _GoogleGenerativeAIEmbeddingModel {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
static [WORKFLOW_DESERIALIZE](options) {
|
|
128
|
-
return new
|
|
129
|
-
options.modelId,
|
|
130
|
-
options.config
|
|
131
|
-
);
|
|
128
|
+
return new _GoogleEmbeddingModel(options.modelId, options.config);
|
|
132
129
|
}
|
|
133
130
|
get provider() {
|
|
134
131
|
return this.config.provider;
|
|
@@ -247,7 +244,7 @@ var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema3(
|
|
|
247
244
|
)
|
|
248
245
|
);
|
|
249
246
|
|
|
250
|
-
// src/google-
|
|
247
|
+
// src/google-language-model.ts
|
|
251
248
|
import {
|
|
252
249
|
combineHeaders as combineHeaders2,
|
|
253
250
|
createEventSourceResponseHandler,
|
|
@@ -267,8 +264,8 @@ import {
|
|
|
267
264
|
} from "@ai-sdk/provider-utils";
|
|
268
265
|
import { z as z5 } from "zod/v4";
|
|
269
266
|
|
|
270
|
-
// src/convert-google-
|
|
271
|
-
function
|
|
267
|
+
// src/convert-google-usage.ts
|
|
268
|
+
function convertGoogleUsage(usage) {
|
|
272
269
|
var _a, _b, _c, _d;
|
|
273
270
|
if (usage == null) {
|
|
274
271
|
return {
|
|
@@ -422,7 +419,7 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
|
422
419
|
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
|
423
420
|
}
|
|
424
421
|
|
|
425
|
-
// src/convert-to-google-
|
|
422
|
+
// src/convert-to-google-messages.ts
|
|
426
423
|
import {
|
|
427
424
|
UnsupportedFunctionalityError
|
|
428
425
|
} from "@ai-sdk/provider";
|
|
@@ -537,7 +534,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue) {
|
|
|
537
534
|
}
|
|
538
535
|
}
|
|
539
536
|
}
|
|
540
|
-
function
|
|
537
|
+
function convertToGoogleMessages(prompt, options) {
|
|
541
538
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
542
539
|
const systemInstructionParts = [];
|
|
543
540
|
const contents = [];
|
|
@@ -755,7 +752,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
755
752
|
name: part.toolName,
|
|
756
753
|
response: {
|
|
757
754
|
name: part.toolName,
|
|
758
|
-
content: output.type === "execution-denied" ? (_h = output.reason) != null ? _h : "Tool execution denied." : output.value
|
|
755
|
+
content: output.type === "execution-denied" ? (_h = output.reason) != null ? _h : "Tool call execution denied." : output.value
|
|
759
756
|
}
|
|
760
757
|
}
|
|
761
758
|
});
|
|
@@ -784,7 +781,7 @@ function getModelPath(modelId) {
|
|
|
784
781
|
return modelId.includes("/") ? modelId : `models/${modelId}`;
|
|
785
782
|
}
|
|
786
783
|
|
|
787
|
-
// src/google-
|
|
784
|
+
// src/google-options.ts
|
|
788
785
|
import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
|
|
789
786
|
import { z as z4 } from "zod/v4";
|
|
790
787
|
var googleLanguageModelOptions = lazySchema4(
|
|
@@ -808,7 +805,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
808
805
|
*
|
|
809
806
|
* This is useful when the JSON Schema contains elements that are
|
|
810
807
|
* not supported by the OpenAPI schema version that
|
|
811
|
-
* Google
|
|
808
|
+
* Google uses. You can use this to disable
|
|
812
809
|
* structured outputs if you need to.
|
|
813
810
|
*/
|
|
814
811
|
structuredOutputs: z4.boolean().optional(),
|
|
@@ -933,7 +930,8 @@ import {
|
|
|
933
930
|
function prepareTools({
|
|
934
931
|
tools,
|
|
935
932
|
toolChoice,
|
|
936
|
-
modelId
|
|
933
|
+
modelId,
|
|
934
|
+
isVertexProvider = false
|
|
937
935
|
}) {
|
|
938
936
|
var _a, _b;
|
|
939
937
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1069,7 +1067,9 @@ function prepareTools({
|
|
|
1069
1067
|
}
|
|
1070
1068
|
const combinedToolConfig = {
|
|
1071
1069
|
functionCallingConfig: { mode: "VALIDATED" },
|
|
1072
|
-
|
|
1070
|
+
...!isVertexProvider && {
|
|
1071
|
+
includeServerSideToolInvocations: true
|
|
1072
|
+
}
|
|
1073
1073
|
};
|
|
1074
1074
|
if (toolChoice != null) {
|
|
1075
1075
|
switch (toolChoice.type) {
|
|
@@ -1401,8 +1401,8 @@ function resolvePartialArgValue(arg) {
|
|
|
1401
1401
|
return void 0;
|
|
1402
1402
|
}
|
|
1403
1403
|
|
|
1404
|
-
// src/map-google-
|
|
1405
|
-
function
|
|
1404
|
+
// src/map-google-finish-reason.ts
|
|
1405
|
+
function mapGoogleFinishReason({
|
|
1406
1406
|
finishReason,
|
|
1407
1407
|
hasToolCalls
|
|
1408
1408
|
}) {
|
|
@@ -1427,8 +1427,8 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
1427
1427
|
}
|
|
1428
1428
|
}
|
|
1429
1429
|
|
|
1430
|
-
// src/google-
|
|
1431
|
-
var
|
|
1430
|
+
// src/google-language-model.ts
|
|
1431
|
+
var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
1432
1432
|
constructor(modelId, config) {
|
|
1433
1433
|
this.specificationVersion = "v4";
|
|
1434
1434
|
var _a;
|
|
@@ -1443,7 +1443,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
1443
1443
|
});
|
|
1444
1444
|
}
|
|
1445
1445
|
static [WORKFLOW_DESERIALIZE2](options) {
|
|
1446
|
-
return new
|
|
1446
|
+
return new _GoogleLanguageModel(options.modelId, options.config);
|
|
1447
1447
|
}
|
|
1448
1448
|
get provider() {
|
|
1449
1449
|
return this.config.provider;
|
|
@@ -1504,14 +1504,11 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
1504
1504
|
}
|
|
1505
1505
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1506
1506
|
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
1507
|
-
const { contents, systemInstruction } =
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
supportsFunctionResponseParts
|
|
1513
|
-
}
|
|
1514
|
-
);
|
|
1507
|
+
const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
|
|
1508
|
+
isGemmaModel,
|
|
1509
|
+
providerOptionsName,
|
|
1510
|
+
supportsFunctionResponseParts
|
|
1511
|
+
});
|
|
1515
1512
|
const {
|
|
1516
1513
|
tools: googleTools2,
|
|
1517
1514
|
toolConfig: googleToolConfig,
|
|
@@ -1519,7 +1516,8 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
1519
1516
|
} = prepareTools({
|
|
1520
1517
|
tools,
|
|
1521
1518
|
toolChoice,
|
|
1522
|
-
modelId: this.modelId
|
|
1519
|
+
modelId: this.modelId,
|
|
1520
|
+
isVertexProvider
|
|
1523
1521
|
});
|
|
1524
1522
|
const resolvedThinking = resolveThinkingConfig({
|
|
1525
1523
|
reasoning,
|
|
@@ -1734,7 +1732,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
1734
1732
|
return {
|
|
1735
1733
|
content,
|
|
1736
1734
|
finishReason: {
|
|
1737
|
-
unified:
|
|
1735
|
+
unified: mapGoogleFinishReason({
|
|
1738
1736
|
finishReason: candidate.finishReason,
|
|
1739
1737
|
// Only count client-executed tool calls for finish reason determination.
|
|
1740
1738
|
hasToolCalls: content.some(
|
|
@@ -1743,7 +1741,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
1743
1741
|
}),
|
|
1744
1742
|
raw: (_j = candidate.finishReason) != null ? _j : void 0
|
|
1745
1743
|
},
|
|
1746
|
-
usage:
|
|
1744
|
+
usage: convertGoogleUsage(usageMetadata),
|
|
1747
1745
|
warnings,
|
|
1748
1746
|
providerMetadata: {
|
|
1749
1747
|
[providerOptionsName]: {
|
|
@@ -2112,7 +2110,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
2112
2110
|
}
|
|
2113
2111
|
if (candidate.finishReason != null) {
|
|
2114
2112
|
finishReason = {
|
|
2115
|
-
unified:
|
|
2113
|
+
unified: mapGoogleFinishReason({
|
|
2116
2114
|
finishReason: candidate.finishReason,
|
|
2117
2115
|
hasToolCalls
|
|
2118
2116
|
}),
|
|
@@ -2147,7 +2145,7 @@ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
|
2147
2145
|
controller.enqueue({
|
|
2148
2146
|
type: "finish",
|
|
2149
2147
|
finishReason,
|
|
2150
|
-
usage:
|
|
2148
|
+
usage: convertGoogleUsage(usage),
|
|
2151
2149
|
providerMetadata
|
|
2152
2150
|
});
|
|
2153
2151
|
}
|
|
@@ -2511,9 +2509,9 @@ var chunkSchema = lazySchema5(
|
|
|
2511
2509
|
);
|
|
2512
2510
|
|
|
2513
2511
|
// src/tool/code-execution.ts
|
|
2514
|
-
import {
|
|
2512
|
+
import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
|
|
2515
2513
|
import { z as z6 } from "zod/v4";
|
|
2516
|
-
var codeExecution =
|
|
2514
|
+
var codeExecution = createProviderExecutedToolFactory({
|
|
2517
2515
|
id: "google.code_execution",
|
|
2518
2516
|
inputSchema: z6.object({
|
|
2519
2517
|
language: z6.string().describe("The programming language of the code."),
|
|
@@ -2527,19 +2525,20 @@ var codeExecution = createProviderToolFactoryWithOutputSchema({
|
|
|
2527
2525
|
|
|
2528
2526
|
// src/tool/enterprise-web-search.ts
|
|
2529
2527
|
import {
|
|
2530
|
-
|
|
2528
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
|
|
2531
2529
|
lazySchema as lazySchema6,
|
|
2532
2530
|
zodSchema as zodSchema6
|
|
2533
2531
|
} from "@ai-sdk/provider-utils";
|
|
2534
2532
|
import { z as z7 } from "zod/v4";
|
|
2535
|
-
var enterpriseWebSearch =
|
|
2533
|
+
var enterpriseWebSearch = createProviderExecutedToolFactory2({
|
|
2536
2534
|
id: "google.enterprise_web_search",
|
|
2537
|
-
inputSchema: lazySchema6(() => zodSchema6(z7.object({})))
|
|
2535
|
+
inputSchema: lazySchema6(() => zodSchema6(z7.object({}))),
|
|
2536
|
+
outputSchema: lazySchema6(() => zodSchema6(z7.object({})))
|
|
2538
2537
|
});
|
|
2539
2538
|
|
|
2540
2539
|
// src/tool/file-search.ts
|
|
2541
2540
|
import {
|
|
2542
|
-
|
|
2541
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
2543
2542
|
lazySchema as lazySchema7,
|
|
2544
2543
|
zodSchema as zodSchema7
|
|
2545
2544
|
} from "@ai-sdk/provider-utils";
|
|
@@ -2560,29 +2559,28 @@ var fileSearchArgsBaseSchema = z8.object({
|
|
|
2560
2559
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
2561
2560
|
).optional()
|
|
2562
2561
|
}).passthrough();
|
|
2563
|
-
var
|
|
2564
|
-
() => zodSchema7(fileSearchArgsBaseSchema)
|
|
2565
|
-
);
|
|
2566
|
-
var fileSearch = createProviderToolFactory2({
|
|
2562
|
+
var fileSearch = createProviderExecutedToolFactory3({
|
|
2567
2563
|
id: "google.file_search",
|
|
2568
|
-
inputSchema:
|
|
2564
|
+
inputSchema: lazySchema7(() => zodSchema7(z8.object({}))),
|
|
2565
|
+
outputSchema: lazySchema7(() => zodSchema7(z8.object({})))
|
|
2569
2566
|
});
|
|
2570
2567
|
|
|
2571
2568
|
// src/tool/google-maps.ts
|
|
2572
2569
|
import {
|
|
2573
|
-
|
|
2570
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
2574
2571
|
lazySchema as lazySchema8,
|
|
2575
2572
|
zodSchema as zodSchema8
|
|
2576
2573
|
} from "@ai-sdk/provider-utils";
|
|
2577
2574
|
import { z as z9 } from "zod/v4";
|
|
2578
|
-
var googleMaps =
|
|
2575
|
+
var googleMaps = createProviderExecutedToolFactory4({
|
|
2579
2576
|
id: "google.google_maps",
|
|
2580
|
-
inputSchema: lazySchema8(() => zodSchema8(z9.object({})))
|
|
2577
|
+
inputSchema: lazySchema8(() => zodSchema8(z9.object({}))),
|
|
2578
|
+
outputSchema: lazySchema8(() => zodSchema8(z9.object({})))
|
|
2581
2579
|
});
|
|
2582
2580
|
|
|
2583
2581
|
// src/tool/google-search.ts
|
|
2584
2582
|
import {
|
|
2585
|
-
|
|
2583
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
|
|
2586
2584
|
lazySchema as lazySchema9,
|
|
2587
2585
|
zodSchema as zodSchema9
|
|
2588
2586
|
} from "@ai-sdk/provider-utils";
|
|
@@ -2597,37 +2595,36 @@ var googleSearchToolArgsBaseSchema = z10.object({
|
|
|
2597
2595
|
endTime: z10.string()
|
|
2598
2596
|
}).optional()
|
|
2599
2597
|
}).passthrough();
|
|
2600
|
-
var
|
|
2601
|
-
|
|
2602
|
-
)
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
id: "google.google_search",
|
|
2606
|
-
inputSchema: googleSearchToolArgsSchema
|
|
2607
|
-
}
|
|
2608
|
-
);
|
|
2598
|
+
var googleSearch = createProviderExecutedToolFactory5({
|
|
2599
|
+
id: "google.google_search",
|
|
2600
|
+
inputSchema: lazySchema9(() => zodSchema9(z10.object({}))),
|
|
2601
|
+
outputSchema: lazySchema9(() => zodSchema9(z10.object({})))
|
|
2602
|
+
});
|
|
2609
2603
|
|
|
2610
2604
|
// src/tool/url-context.ts
|
|
2611
2605
|
import {
|
|
2612
|
-
|
|
2606
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
|
|
2613
2607
|
lazySchema as lazySchema10,
|
|
2614
2608
|
zodSchema as zodSchema10
|
|
2615
2609
|
} from "@ai-sdk/provider-utils";
|
|
2616
2610
|
import { z as z11 } from "zod/v4";
|
|
2617
|
-
var urlContext =
|
|
2611
|
+
var urlContext = createProviderExecutedToolFactory6({
|
|
2618
2612
|
id: "google.url_context",
|
|
2619
|
-
inputSchema: lazySchema10(() => zodSchema10(z11.object({})))
|
|
2613
|
+
inputSchema: lazySchema10(() => zodSchema10(z11.object({}))),
|
|
2614
|
+
outputSchema: lazySchema10(() => zodSchema10(z11.object({})))
|
|
2620
2615
|
});
|
|
2621
2616
|
|
|
2622
2617
|
// src/tool/vertex-rag-store.ts
|
|
2623
|
-
import {
|
|
2618
|
+
import {
|
|
2619
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
|
|
2620
|
+
lazySchema as lazySchema11,
|
|
2621
|
+
zodSchema as zodSchema11
|
|
2622
|
+
} from "@ai-sdk/provider-utils";
|
|
2624
2623
|
import { z as z12 } from "zod/v4";
|
|
2625
|
-
var vertexRagStore =
|
|
2624
|
+
var vertexRagStore = createProviderExecutedToolFactory7({
|
|
2626
2625
|
id: "google.vertex_rag_store",
|
|
2627
|
-
inputSchema: z12.object({
|
|
2628
|
-
|
|
2629
|
-
topK: z12.number().optional()
|
|
2630
|
-
})
|
|
2626
|
+
inputSchema: lazySchema11(() => zodSchema11(z12.object({}))),
|
|
2627
|
+
outputSchema: lazySchema11(() => zodSchema11(z12.object({})))
|
|
2631
2628
|
});
|
|
2632
2629
|
|
|
2633
2630
|
// src/google-tools.ts
|
|
@@ -2690,23 +2687,23 @@ var googleTools = {
|
|
|
2690
2687
|
vertexRagStore
|
|
2691
2688
|
};
|
|
2692
2689
|
|
|
2693
|
-
// src/google-
|
|
2690
|
+
// src/google-image-model.ts
|
|
2694
2691
|
import {
|
|
2695
2692
|
combineHeaders as combineHeaders3,
|
|
2696
2693
|
convertToBase64 as convertToBase642,
|
|
2697
2694
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
2698
2695
|
generateId as defaultGenerateId,
|
|
2699
|
-
lazySchema as
|
|
2696
|
+
lazySchema as lazySchema12,
|
|
2700
2697
|
parseProviderOptions as parseProviderOptions3,
|
|
2701
2698
|
postJsonToApi as postJsonToApi3,
|
|
2702
2699
|
resolve as resolve3,
|
|
2703
2700
|
serializeModelOptions as serializeModelOptions3,
|
|
2704
2701
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
|
|
2705
2702
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3,
|
|
2706
|
-
zodSchema as
|
|
2703
|
+
zodSchema as zodSchema12
|
|
2707
2704
|
} from "@ai-sdk/provider-utils";
|
|
2708
2705
|
import { z as z13 } from "zod/v4";
|
|
2709
|
-
var
|
|
2706
|
+
var GoogleImageModel = class _GoogleImageModel {
|
|
2710
2707
|
constructor(modelId, settings, config) {
|
|
2711
2708
|
this.modelId = modelId;
|
|
2712
2709
|
this.settings = settings;
|
|
@@ -2720,11 +2717,7 @@ var GoogleGenerativeAIImageModel = class _GoogleGenerativeAIImageModel {
|
|
|
2720
2717
|
});
|
|
2721
2718
|
}
|
|
2722
2719
|
static [WORKFLOW_DESERIALIZE3](options) {
|
|
2723
|
-
return new
|
|
2724
|
-
options.modelId,
|
|
2725
|
-
{},
|
|
2726
|
-
options.config
|
|
2727
|
-
);
|
|
2720
|
+
return new _GoogleImageModel(options.modelId, {}, options.config);
|
|
2728
2721
|
}
|
|
2729
2722
|
get maxImagesPerCall() {
|
|
2730
2723
|
if (this.settings.maxImagesPerCall != null) {
|
|
@@ -2761,12 +2754,12 @@ var GoogleGenerativeAIImageModel = class _GoogleGenerativeAIImageModel {
|
|
|
2761
2754
|
const warnings = [];
|
|
2762
2755
|
if (files != null && files.length > 0) {
|
|
2763
2756
|
throw new Error(
|
|
2764
|
-
"Google
|
|
2757
|
+
"Google Gemini API does not support image editing with Imagen models. Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities."
|
|
2765
2758
|
);
|
|
2766
2759
|
}
|
|
2767
2760
|
if (mask != null) {
|
|
2768
2761
|
throw new Error(
|
|
2769
|
-
"Google
|
|
2762
|
+
"Google Gemini API does not support image editing with masks. Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities."
|
|
2770
2763
|
);
|
|
2771
2764
|
}
|
|
2772
2765
|
if (size != null) {
|
|
@@ -2891,7 +2884,7 @@ var GoogleGenerativeAIImageModel = class _GoogleGenerativeAIImageModel {
|
|
|
2891
2884
|
const languageModelPrompt = [
|
|
2892
2885
|
{ role: "user", content: userContent }
|
|
2893
2886
|
];
|
|
2894
|
-
const languageModel = new
|
|
2887
|
+
const languageModel = new GoogleLanguageModel(this.modelId, {
|
|
2895
2888
|
provider: this.config.provider,
|
|
2896
2889
|
baseURL: this.config.baseURL,
|
|
2897
2890
|
headers: (_a = this.config.headers) != null ? _a : {},
|
|
@@ -2944,15 +2937,15 @@ var GoogleGenerativeAIImageModel = class _GoogleGenerativeAIImageModel {
|
|
|
2944
2937
|
function isGeminiModel(modelId) {
|
|
2945
2938
|
return modelId.startsWith("gemini-");
|
|
2946
2939
|
}
|
|
2947
|
-
var googleImageResponseSchema =
|
|
2948
|
-
() =>
|
|
2940
|
+
var googleImageResponseSchema = lazySchema12(
|
|
2941
|
+
() => zodSchema12(
|
|
2949
2942
|
z13.object({
|
|
2950
2943
|
predictions: z13.array(z13.object({ bytesBase64Encoded: z13.string() })).default([])
|
|
2951
2944
|
})
|
|
2952
2945
|
)
|
|
2953
2946
|
);
|
|
2954
|
-
var googleImageModelOptionsSchema =
|
|
2955
|
-
() =>
|
|
2947
|
+
var googleImageModelOptionsSchema = lazySchema12(
|
|
2948
|
+
() => zodSchema12(
|
|
2956
2949
|
z13.object({
|
|
2957
2950
|
personGeneration: z13.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
2958
2951
|
aspectRatio: z13.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
@@ -2960,7 +2953,7 @@ var googleImageModelOptionsSchema = lazySchema11(
|
|
|
2960
2953
|
)
|
|
2961
2954
|
);
|
|
2962
2955
|
|
|
2963
|
-
// src/google-
|
|
2956
|
+
// src/google-files.ts
|
|
2964
2957
|
import {
|
|
2965
2958
|
AISDKError
|
|
2966
2959
|
} from "@ai-sdk/provider";
|
|
@@ -2968,13 +2961,13 @@ import {
|
|
|
2968
2961
|
combineHeaders as combineHeaders4,
|
|
2969
2962
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
2970
2963
|
delay,
|
|
2971
|
-
lazySchema as
|
|
2964
|
+
lazySchema as lazySchema13,
|
|
2972
2965
|
parseProviderOptions as parseProviderOptions4,
|
|
2973
|
-
zodSchema as
|
|
2966
|
+
zodSchema as zodSchema13,
|
|
2974
2967
|
getFromApi
|
|
2975
2968
|
} from "@ai-sdk/provider-utils";
|
|
2976
2969
|
import { z as z14 } from "zod/v4";
|
|
2977
|
-
var
|
|
2970
|
+
var GoogleFiles = class {
|
|
2978
2971
|
constructor(config) {
|
|
2979
2972
|
this.config = config;
|
|
2980
2973
|
this.specificationVersion = "v4";
|
|
@@ -3097,8 +3090,8 @@ var GoogleGenerativeAIFiles = class {
|
|
|
3097
3090
|
};
|
|
3098
3091
|
}
|
|
3099
3092
|
};
|
|
3100
|
-
var googleFileResponseSchema =
|
|
3101
|
-
() =>
|
|
3093
|
+
var googleFileResponseSchema = lazySchema13(
|
|
3094
|
+
() => zodSchema13(
|
|
3102
3095
|
z14.object({
|
|
3103
3096
|
name: z14.string(),
|
|
3104
3097
|
displayName: z14.string().nullish(),
|
|
@@ -3113,8 +3106,8 @@ var googleFileResponseSchema = lazySchema12(
|
|
|
3113
3106
|
})
|
|
3114
3107
|
)
|
|
3115
3108
|
);
|
|
3116
|
-
var googleFilesUploadOptionsSchema =
|
|
3117
|
-
() =>
|
|
3109
|
+
var googleFilesUploadOptionsSchema = lazySchema13(
|
|
3110
|
+
() => zodSchema13(
|
|
3118
3111
|
z14.object({
|
|
3119
3112
|
displayName: z14.string().nullish(),
|
|
3120
3113
|
pollIntervalMs: z14.number().positive().nullish(),
|
|
@@ -3123,7 +3116,7 @@ var googleFilesUploadOptionsSchema = lazySchema12(
|
|
|
3123
3116
|
)
|
|
3124
3117
|
);
|
|
3125
3118
|
|
|
3126
|
-
// src/google-
|
|
3119
|
+
// src/google-video-model.ts
|
|
3127
3120
|
import {
|
|
3128
3121
|
AISDKError as AISDKError2
|
|
3129
3122
|
} from "@ai-sdk/provider";
|
|
@@ -3133,14 +3126,14 @@ import {
|
|
|
3133
3126
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
3134
3127
|
delay as delay2,
|
|
3135
3128
|
getFromApi as getFromApi2,
|
|
3136
|
-
lazySchema as
|
|
3129
|
+
lazySchema as lazySchema14,
|
|
3137
3130
|
parseProviderOptions as parseProviderOptions5,
|
|
3138
3131
|
postJsonToApi as postJsonToApi4,
|
|
3139
3132
|
resolve as resolve4,
|
|
3140
|
-
zodSchema as
|
|
3133
|
+
zodSchema as zodSchema14
|
|
3141
3134
|
} from "@ai-sdk/provider-utils";
|
|
3142
3135
|
import { z as z15 } from "zod/v4";
|
|
3143
|
-
var
|
|
3136
|
+
var GoogleVideoModel = class {
|
|
3144
3137
|
constructor(modelId, config) {
|
|
3145
3138
|
this.modelId = modelId;
|
|
3146
3139
|
this.config = config;
|
|
@@ -3371,8 +3364,8 @@ var googleOperationSchema = z15.object({
|
|
|
3371
3364
|
}).nullish()
|
|
3372
3365
|
}).nullish()
|
|
3373
3366
|
});
|
|
3374
|
-
var googleVideoModelOptionsSchema =
|
|
3375
|
-
() =>
|
|
3367
|
+
var googleVideoModelOptionsSchema = lazySchema14(
|
|
3368
|
+
() => zodSchema14(
|
|
3376
3369
|
z15.object({
|
|
3377
3370
|
pollIntervalMs: z15.number().positive().nullish(),
|
|
3378
3371
|
pollTimeoutMs: z15.number().positive().nullish(),
|
|
@@ -3389,7 +3382,7 @@ var googleVideoModelOptionsSchema = lazySchema13(
|
|
|
3389
3382
|
);
|
|
3390
3383
|
|
|
3391
3384
|
// src/google-provider.ts
|
|
3392
|
-
function
|
|
3385
|
+
function createGoogle(options = {}) {
|
|
3393
3386
|
var _a, _b;
|
|
3394
3387
|
const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
3395
3388
|
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
@@ -3406,7 +3399,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
3406
3399
|
);
|
|
3407
3400
|
const createChatModel = (modelId) => {
|
|
3408
3401
|
var _a2;
|
|
3409
|
-
return new
|
|
3402
|
+
return new GoogleLanguageModel(modelId, {
|
|
3410
3403
|
provider: providerName,
|
|
3411
3404
|
baseURL,
|
|
3412
3405
|
headers: getHeaders,
|
|
@@ -3426,19 +3419,19 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
3426
3419
|
fetch: options.fetch
|
|
3427
3420
|
});
|
|
3428
3421
|
};
|
|
3429
|
-
const createEmbeddingModel = (modelId) => new
|
|
3422
|
+
const createEmbeddingModel = (modelId) => new GoogleEmbeddingModel(modelId, {
|
|
3430
3423
|
provider: providerName,
|
|
3431
3424
|
baseURL,
|
|
3432
3425
|
headers: getHeaders,
|
|
3433
3426
|
fetch: options.fetch
|
|
3434
3427
|
});
|
|
3435
|
-
const createImageModel = (modelId, settings = {}) => new
|
|
3428
|
+
const createImageModel = (modelId, settings = {}) => new GoogleImageModel(modelId, settings, {
|
|
3436
3429
|
provider: providerName,
|
|
3437
3430
|
baseURL,
|
|
3438
3431
|
headers: getHeaders,
|
|
3439
3432
|
fetch: options.fetch
|
|
3440
3433
|
});
|
|
3441
|
-
const createFiles = () => new
|
|
3434
|
+
const createFiles = () => new GoogleFiles({
|
|
3442
3435
|
provider: providerName,
|
|
3443
3436
|
baseURL,
|
|
3444
3437
|
headers: getHeaders,
|
|
@@ -3446,7 +3439,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
3446
3439
|
});
|
|
3447
3440
|
const createVideoModel = (modelId) => {
|
|
3448
3441
|
var _a2;
|
|
3449
|
-
return new
|
|
3442
|
+
return new GoogleVideoModel(modelId, {
|
|
3450
3443
|
provider: providerName,
|
|
3451
3444
|
baseURL,
|
|
3452
3445
|
headers: getHeaders,
|
|
@@ -3478,10 +3471,11 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
3478
3471
|
provider.tools = googleTools;
|
|
3479
3472
|
return provider;
|
|
3480
3473
|
}
|
|
3481
|
-
var google =
|
|
3474
|
+
var google = createGoogle();
|
|
3482
3475
|
export {
|
|
3483
3476
|
VERSION,
|
|
3484
|
-
|
|
3477
|
+
createGoogle,
|
|
3478
|
+
createGoogle as createGoogleGenerativeAI,
|
|
3485
3479
|
google
|
|
3486
3480
|
};
|
|
3487
3481
|
//# sourceMappingURL=index.js.map
|