@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/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -180,18 +180,18 @@ declare const googleImageProviderOptionsSchema: _ai_sdk_provider_utils.LazySchem
|
|
|
180
180
|
}>;
|
|
181
181
|
type GoogleGenerativeAIImageProviderOptions = InferValidator<typeof googleImageProviderOptionsSchema>;
|
|
182
182
|
|
|
183
|
-
type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | '
|
|
183
|
+
type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'gemini-embedding-2-preview' | (string & {});
|
|
184
184
|
declare const googleGenerativeAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
185
185
|
outputDimensionality?: number | undefined;
|
|
186
186
|
taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
|
|
187
|
-
content?: ({
|
|
187
|
+
content?: (({
|
|
188
188
|
text: string;
|
|
189
189
|
} | {
|
|
190
190
|
inlineData: {
|
|
191
191
|
mimeType: string;
|
|
192
192
|
data: string;
|
|
193
193
|
};
|
|
194
|
-
})[] | undefined;
|
|
194
|
+
})[] | null)[] | undefined;
|
|
195
195
|
}>;
|
|
196
196
|
type GoogleGenerativeAIEmbeddingProviderOptions = InferValidator<typeof googleGenerativeAIEmbeddingProviderOptions>;
|
|
197
197
|
|
package/dist/index.d.ts
CHANGED
|
@@ -180,18 +180,18 @@ declare const googleImageProviderOptionsSchema: _ai_sdk_provider_utils.LazySchem
|
|
|
180
180
|
}>;
|
|
181
181
|
type GoogleGenerativeAIImageProviderOptions = InferValidator<typeof googleImageProviderOptionsSchema>;
|
|
182
182
|
|
|
183
|
-
type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | '
|
|
183
|
+
type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'gemini-embedding-2-preview' | (string & {});
|
|
184
184
|
declare const googleGenerativeAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
185
185
|
outputDimensionality?: number | undefined;
|
|
186
186
|
taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
|
|
187
|
-
content?: ({
|
|
187
|
+
content?: (({
|
|
188
188
|
text: string;
|
|
189
189
|
} | {
|
|
190
190
|
inlineData: {
|
|
191
191
|
mimeType: string;
|
|
192
192
|
data: string;
|
|
193
193
|
};
|
|
194
|
-
})[] | undefined;
|
|
194
|
+
})[] | null)[] | undefined;
|
|
195
195
|
}>;
|
|
196
196
|
type GoogleGenerativeAIEmbeddingProviderOptions = InferValidator<typeof googleGenerativeAIEmbeddingProviderOptions>;
|
|
197
197
|
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
30
30
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "2.0.
|
|
33
|
+
var VERSION = true ? "2.0.62" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -99,11 +99,15 @@ var googleGenerativeAIEmbeddingProviderOptions = (0, import_provider_utils2.lazy
|
|
|
99
99
|
"CODE_RETRIEVAL_QUERY"
|
|
100
100
|
]).optional(),
|
|
101
101
|
/**
|
|
102
|
-
* Optional.
|
|
103
|
-
* (images, video, PDF, audio).
|
|
104
|
-
*
|
|
102
|
+
* Optional. Per-value multimodal content parts for embedding non-text
|
|
103
|
+
* content (images, video, PDF, audio). Each entry corresponds to the
|
|
104
|
+
* embedding value at the same index and its parts are merged with the
|
|
105
|
+
* text value in the request. Use `null` for entries that are text-only.
|
|
106
|
+
*
|
|
107
|
+
* The array length must match the number of values being embedded. In
|
|
108
|
+
* the case of a single embedding, the array length must be 1.
|
|
105
109
|
*/
|
|
106
|
-
content: import_v42.z.array(googleEmbeddingContentPartSchema).min(1).optional()
|
|
110
|
+
content: import_v42.z.array(import_v42.z.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
|
|
107
111
|
})
|
|
108
112
|
)
|
|
109
113
|
);
|
|
@@ -126,7 +130,6 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
126
130
|
abortSignal,
|
|
127
131
|
providerOptions
|
|
128
132
|
}) {
|
|
129
|
-
var _a;
|
|
130
133
|
const googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
131
134
|
provider: "google",
|
|
132
135
|
providerOptions,
|
|
@@ -144,10 +147,16 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
144
147
|
await (0, import_provider_utils3.resolve)(this.config.headers),
|
|
145
148
|
headers
|
|
146
149
|
);
|
|
147
|
-
const multimodalContent =
|
|
150
|
+
const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
|
|
151
|
+
if (multimodalContent != null && multimodalContent.length !== values.length) {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`The number of multimodal content entries (${multimodalContent.length}) must match the number of values (${values.length}).`
|
|
154
|
+
);
|
|
155
|
+
}
|
|
148
156
|
if (values.length === 1) {
|
|
157
|
+
const valueParts = multimodalContent == null ? void 0 : multimodalContent[0];
|
|
149
158
|
const textPart = values[0] ? [{ text: values[0] }] : [];
|
|
150
|
-
const parts =
|
|
159
|
+
const parts = valueParts != null ? [...textPart, ...valueParts] : [{ text: values[0] }];
|
|
151
160
|
const {
|
|
152
161
|
responseHeaders: responseHeaders2,
|
|
153
162
|
value: response2,
|
|
@@ -184,13 +193,14 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
184
193
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
185
194
|
headers: mergedHeaders,
|
|
186
195
|
body: {
|
|
187
|
-
requests: values.map((value) => {
|
|
196
|
+
requests: values.map((value, index) => {
|
|
197
|
+
const valueParts = multimodalContent == null ? void 0 : multimodalContent[index];
|
|
188
198
|
const textPart = value ? [{ text: value }] : [];
|
|
189
199
|
return {
|
|
190
200
|
model: `models/${this.modelId}`,
|
|
191
201
|
content: {
|
|
192
202
|
role: "user",
|
|
193
|
-
parts:
|
|
203
|
+
parts: valueParts != null ? [...textPart, ...valueParts] : [{ text: value }]
|
|
194
204
|
},
|
|
195
205
|
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
196
206
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|