@ai-sdk/google 2.0.60 → 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 +12 -0
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +44 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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 {
|
|
@@ -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 googleGenerativeAIEmbeddingProviderOptions = lazySchema2(
|
|
57
66
|
() => zodSchema2(
|
|
58
67
|
z2.object({
|
|
@@ -82,7 +91,17 @@ var googleGenerativeAIEmbeddingProviderOptions = lazySchema2(
|
|
|
82
91
|
"QUESTION_ANSWERING",
|
|
83
92
|
"FACT_VERIFICATION",
|
|
84
93
|
"CODE_RETRIEVAL_QUERY"
|
|
85
|
-
]).optional()
|
|
94
|
+
]).optional(),
|
|
95
|
+
/**
|
|
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.
|
|
103
|
+
*/
|
|
104
|
+
content: z2.array(z2.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
|
|
86
105
|
})
|
|
87
106
|
)
|
|
88
107
|
);
|
|
@@ -122,7 +141,16 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
122
141
|
await resolve(this.config.headers),
|
|
123
142
|
headers
|
|
124
143
|
);
|
|
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
|
+
}
|
|
125
150
|
if (values.length === 1) {
|
|
151
|
+
const valueParts = multimodalContent == null ? void 0 : multimodalContent[0];
|
|
152
|
+
const textPart = values[0] ? [{ text: values[0] }] : [];
|
|
153
|
+
const parts = valueParts != null ? [...textPart, ...valueParts] : [{ text: values[0] }];
|
|
126
154
|
const {
|
|
127
155
|
responseHeaders: responseHeaders2,
|
|
128
156
|
value: response2,
|
|
@@ -133,7 +161,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
133
161
|
body: {
|
|
134
162
|
model: `models/${this.modelId}`,
|
|
135
163
|
content: {
|
|
136
|
-
parts
|
|
164
|
+
parts
|
|
137
165
|
},
|
|
138
166
|
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
139
167
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
@@ -159,12 +187,19 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
159
187
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
160
188
|
headers: mergedHeaders,
|
|
161
189
|
body: {
|
|
162
|
-
requests: values.map((value) =>
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
190
|
+
requests: values.map((value, index) => {
|
|
191
|
+
const valueParts = multimodalContent == null ? void 0 : multimodalContent[index];
|
|
192
|
+
const textPart = value ? [{ text: value }] : [];
|
|
193
|
+
return {
|
|
194
|
+
model: `models/${this.modelId}`,
|
|
195
|
+
content: {
|
|
196
|
+
role: "user",
|
|
197
|
+
parts: valueParts != null ? [...textPart, ...valueParts] : [{ text: value }]
|
|
198
|
+
},
|
|
199
|
+
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
200
|
+
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
201
|
+
};
|
|
202
|
+
})
|
|
168
203
|
},
|
|
169
204
|
failedResponseHandler: googleFailedResponseHandler,
|
|
170
205
|
successfulResponseHandler: createJsonResponseHandler(
|