@ai-sdk/google 2.0.61 → 2.0.62
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 +6 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 ? "2.0.
|
|
10
|
+
var VERSION = true ? "2.0.62" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -93,11 +93,15 @@ var googleGenerativeAIEmbeddingProviderOptions = lazySchema2(
|
|
|
93
93
|
"CODE_RETRIEVAL_QUERY"
|
|
94
94
|
]).optional(),
|
|
95
95
|
/**
|
|
96
|
-
* Optional.
|
|
97
|
-
* (images, video, PDF, audio).
|
|
98
|
-
*
|
|
96
|
+
* Optional. Per-value multimodal content parts for embedding non-text
|
|
97
|
+
* content (images, video, PDF, audio). Each entry corresponds to the
|
|
98
|
+
* embedding value at the same index and its parts are merged with the
|
|
99
|
+
* text value in the request. Use `null` for entries that are text-only.
|
|
100
|
+
*
|
|
101
|
+
* The array length must match the number of values being embedded. In
|
|
102
|
+
* the case of a single embedding, the array length must be 1.
|
|
99
103
|
*/
|
|
100
|
-
content: z2.array(googleEmbeddingContentPartSchema).min(1).optional()
|
|
104
|
+
content: z2.array(z2.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
|
|
101
105
|
})
|
|
102
106
|
)
|
|
103
107
|
);
|
|
@@ -120,7 +124,6 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
120
124
|
abortSignal,
|
|
121
125
|
providerOptions
|
|
122
126
|
}) {
|
|
123
|
-
var _a;
|
|
124
127
|
const googleOptions = await parseProviderOptions({
|
|
125
128
|
provider: "google",
|
|
126
129
|
providerOptions,
|
|
@@ -138,10 +141,16 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
138
141
|
await resolve(this.config.headers),
|
|
139
142
|
headers
|
|
140
143
|
);
|
|
141
|
-
const multimodalContent =
|
|
144
|
+
const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
|
|
145
|
+
if (multimodalContent != null && multimodalContent.length !== values.length) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
`The number of multimodal content entries (${multimodalContent.length}) must match the number of values (${values.length}).`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
142
150
|
if (values.length === 1) {
|
|
151
|
+
const valueParts = multimodalContent == null ? void 0 : multimodalContent[0];
|
|
143
152
|
const textPart = values[0] ? [{ text: values[0] }] : [];
|
|
144
|
-
const parts =
|
|
153
|
+
const parts = valueParts != null ? [...textPart, ...valueParts] : [{ text: values[0] }];
|
|
145
154
|
const {
|
|
146
155
|
responseHeaders: responseHeaders2,
|
|
147
156
|
value: response2,
|
|
@@ -178,13 +187,14 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
178
187
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
179
188
|
headers: mergedHeaders,
|
|
180
189
|
body: {
|
|
181
|
-
requests: values.map((value) => {
|
|
190
|
+
requests: values.map((value, index) => {
|
|
191
|
+
const valueParts = multimodalContent == null ? void 0 : multimodalContent[index];
|
|
182
192
|
const textPart = value ? [{ text: value }] : [];
|
|
183
193
|
return {
|
|
184
194
|
model: `models/${this.modelId}`,
|
|
185
195
|
content: {
|
|
186
196
|
role: "user",
|
|
187
|
-
parts:
|
|
197
|
+
parts: valueParts != null ? [...textPart, ...valueParts] : [{ text: value }]
|
|
188
198
|
},
|
|
189
199
|
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
190
200
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|