@ai-sdk/google 3.0.46 → 3.0.48
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 +12 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +47 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -0
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +13 -5
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +13 -5
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/convert-to-google-generative-ai-messages.ts +3 -0
- package/src/google-generative-ai-embedding-model.ts +27 -8
- package/src/google-generative-ai-embedding-options.ts +17 -0
- package/src/google-generative-ai-language-model.ts +28 -16
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.48" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -53,6 +53,15 @@ import {
|
|
|
53
53
|
zodSchema as zodSchema2
|
|
54
54
|
} from "@ai-sdk/provider-utils";
|
|
55
55
|
import { z as z2 } from "zod/v4";
|
|
56
|
+
var googleEmbeddingContentPartSchema = z2.union([
|
|
57
|
+
z2.object({ text: z2.string() }),
|
|
58
|
+
z2.object({
|
|
59
|
+
inlineData: z2.object({
|
|
60
|
+
mimeType: z2.string(),
|
|
61
|
+
data: z2.string()
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
]);
|
|
56
65
|
var googleEmbeddingModelOptions = lazySchema2(
|
|
57
66
|
() => zodSchema2(
|
|
58
67
|
z2.object({
|
|
@@ -82,7 +91,13 @@ var googleEmbeddingModelOptions = lazySchema2(
|
|
|
82
91
|
"QUESTION_ANSWERING",
|
|
83
92
|
"FACT_VERIFICATION",
|
|
84
93
|
"CODE_RETRIEVAL_QUERY"
|
|
85
|
-
]).optional()
|
|
94
|
+
]).optional(),
|
|
95
|
+
/**
|
|
96
|
+
* Optional. Multimodal content parts for embedding non-text content
|
|
97
|
+
* (images, video, PDF, audio). When provided, these parts are used
|
|
98
|
+
* instead of the text values in the embedding request.
|
|
99
|
+
*/
|
|
100
|
+
content: z2.array(googleEmbeddingContentPartSchema).min(1).optional()
|
|
86
101
|
})
|
|
87
102
|
)
|
|
88
103
|
);
|
|
@@ -105,6 +120,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
105
120
|
abortSignal,
|
|
106
121
|
providerOptions
|
|
107
122
|
}) {
|
|
123
|
+
var _a;
|
|
108
124
|
const googleOptions = await parseProviderOptions({
|
|
109
125
|
provider: "google",
|
|
110
126
|
providerOptions,
|
|
@@ -122,7 +138,10 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
122
138
|
await resolve(this.config.headers),
|
|
123
139
|
headers
|
|
124
140
|
);
|
|
141
|
+
const multimodalContent = (_a = googleOptions == null ? void 0 : googleOptions.content) != null ? _a : [];
|
|
125
142
|
if (values.length === 1) {
|
|
143
|
+
const textPart = values[0] ? [{ text: values[0] }] : [];
|
|
144
|
+
const parts = multimodalContent.length > 0 ? [...textPart, ...multimodalContent] : [{ text: values[0] }];
|
|
126
145
|
const {
|
|
127
146
|
responseHeaders: responseHeaders2,
|
|
128
147
|
value: response2,
|
|
@@ -133,7 +152,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
133
152
|
body: {
|
|
134
153
|
model: `models/${this.modelId}`,
|
|
135
154
|
content: {
|
|
136
|
-
parts
|
|
155
|
+
parts
|
|
137
156
|
},
|
|
138
157
|
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
139
158
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
@@ -160,12 +179,18 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
160
179
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
161
180
|
headers: mergedHeaders,
|
|
162
181
|
body: {
|
|
163
|
-
requests: values.map((value) =>
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
182
|
+
requests: values.map((value) => {
|
|
183
|
+
const textPart = value ? [{ text: value }] : [];
|
|
184
|
+
return {
|
|
185
|
+
model: `models/${this.modelId}`,
|
|
186
|
+
content: {
|
|
187
|
+
role: "user",
|
|
188
|
+
parts: multimodalContent.length > 0 ? [...textPart, ...multimodalContent] : [{ text: value }]
|
|
189
|
+
},
|
|
190
|
+
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
191
|
+
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
192
|
+
};
|
|
193
|
+
})
|
|
169
194
|
},
|
|
170
195
|
failedResponseHandler: googleFailedResponseHandler,
|
|
171
196
|
successfulResponseHandler: createJsonResponseHandler(
|
|
@@ -453,6 +478,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
453
478
|
mimeType: part.mediaType,
|
|
454
479
|
data: convertToBase64(part.data)
|
|
455
480
|
},
|
|
481
|
+
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
456
482
|
thoughtSignature
|
|
457
483
|
};
|
|
458
484
|
}
|
|
@@ -1100,13 +1126,16 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1100
1126
|
} : void 0
|
|
1101
1127
|
});
|
|
1102
1128
|
} else if ("inlineData" in part) {
|
|
1129
|
+
const hasThought = part.thought === true;
|
|
1130
|
+
const hasThoughtSignature = !!part.thoughtSignature;
|
|
1103
1131
|
content.push({
|
|
1104
1132
|
type: "file",
|
|
1105
1133
|
data: part.inlineData.data,
|
|
1106
1134
|
mediaType: part.inlineData.mimeType,
|
|
1107
|
-
providerMetadata:
|
|
1135
|
+
providerMetadata: hasThought || hasThoughtSignature ? {
|
|
1108
1136
|
[providerOptionsName]: {
|
|
1109
|
-
|
|
1137
|
+
...hasThought ? { thought: true } : {},
|
|
1138
|
+
...hasThoughtSignature ? { thoughtSignature: part.thoughtSignature } : {}
|
|
1110
1139
|
}
|
|
1111
1140
|
} : void 0
|
|
1112
1141
|
});
|
|
@@ -1327,16 +1356,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1327
1356
|
});
|
|
1328
1357
|
currentReasoningBlockId = null;
|
|
1329
1358
|
}
|
|
1330
|
-
const
|
|
1359
|
+
const hasThought = part.thought === true;
|
|
1360
|
+
const hasThoughtSignature = !!part.thoughtSignature;
|
|
1361
|
+
const fileMeta = hasThought || hasThoughtSignature ? {
|
|
1331
1362
|
[providerOptionsName]: {
|
|
1332
|
-
|
|
1363
|
+
...hasThought ? { thought: true } : {},
|
|
1364
|
+
...hasThoughtSignature ? { thoughtSignature: part.thoughtSignature } : {}
|
|
1333
1365
|
}
|
|
1334
1366
|
} : void 0;
|
|
1335
1367
|
controller.enqueue({
|
|
1336
1368
|
type: "file",
|
|
1337
1369
|
mediaType: part.inlineData.mimeType,
|
|
1338
1370
|
data: part.inlineData.data,
|
|
1339
|
-
providerMetadata:
|
|
1371
|
+
providerMetadata: fileMeta
|
|
1340
1372
|
});
|
|
1341
1373
|
}
|
|
1342
1374
|
}
|
|
@@ -1602,6 +1634,7 @@ var getContentSchema = () => z5.object({
|
|
|
1602
1634
|
mimeType: z5.string(),
|
|
1603
1635
|
data: z5.string()
|
|
1604
1636
|
}),
|
|
1637
|
+
thought: z5.boolean().nullish(),
|
|
1605
1638
|
thoughtSignature: z5.string().nullish()
|
|
1606
1639
|
}),
|
|
1607
1640
|
z5.object({
|