@ai-sdk/google 3.0.49 → 3.0.50

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 3.0.50
4
+
5
+ ### Patch Changes
6
+
7
+ - 5ffb1ad: feat(provider/google): add `gemini-embedding-2-preview` and fix multimodal embedding support with `embedMany`
8
+
3
9
  ## 3.0.49
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -182,18 +182,18 @@ declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
182
182
  }>;
183
183
  type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
184
184
 
185
- type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | (string & {});
185
+ type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'gemini-embedding-2-preview' | (string & {});
186
186
  declare const googleEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
187
187
  outputDimensionality?: number | undefined;
188
188
  taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
189
- content?: ({
189
+ content?: (({
190
190
  text: string;
191
191
  } | {
192
192
  inlineData: {
193
193
  mimeType: string;
194
194
  data: string;
195
195
  };
196
- })[] | undefined;
196
+ })[] | null)[] | undefined;
197
197
  }>;
198
198
  type GoogleEmbeddingModelOptions = InferSchema<typeof googleEmbeddingModelOptions>;
199
199
 
package/dist/index.d.ts CHANGED
@@ -182,18 +182,18 @@ declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
182
182
  }>;
183
183
  type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
184
184
 
185
- type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | (string & {});
185
+ type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'gemini-embedding-2-preview' | (string & {});
186
186
  declare const googleEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
187
187
  outputDimensionality?: number | undefined;
188
188
  taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
189
- content?: ({
189
+ content?: (({
190
190
  text: string;
191
191
  } | {
192
192
  inlineData: {
193
193
  mimeType: string;
194
194
  data: string;
195
195
  };
196
- })[] | undefined;
196
+ })[] | null)[] | undefined;
197
197
  }>;
198
198
  type GoogleEmbeddingModelOptions = InferSchema<typeof googleEmbeddingModelOptions>;
199
199
 
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "3.0.49" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.50" : "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 googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
99
99
  "CODE_RETRIEVAL_QUERY"
100
100
  ]).optional(),
101
101
  /**
102
- * Optional. Multimodal content parts for embedding non-text content
103
- * (images, video, PDF, audio). When provided, these parts are merged
104
- * with the text values in the embedding request.
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 = (_a = googleOptions == null ? void 0 : googleOptions.content) != null ? _a : [];
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 = multimodalContent.length > 0 ? [...textPart, ...multimodalContent] : [{ text: values[0] }];
159
+ const parts = valueParts != null ? [...textPart, ...valueParts] : [{ text: values[0] }];
151
160
  const {
152
161
  responseHeaders: responseHeaders2,
153
162
  value: response2,
@@ -185,13 +194,14 @@ var GoogleGenerativeAIEmbeddingModel = class {
185
194
  url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
186
195
  headers: mergedHeaders,
187
196
  body: {
188
- requests: values.map((value) => {
197
+ requests: values.map((value, index) => {
198
+ const valueParts = multimodalContent == null ? void 0 : multimodalContent[index];
189
199
  const textPart = value ? [{ text: value }] : [];
190
200
  return {
191
201
  model: `models/${this.modelId}`,
192
202
  content: {
193
203
  role: "user",
194
- parts: multimodalContent.length > 0 ? [...textPart, ...multimodalContent] : [{ text: value }]
204
+ parts: valueParts != null ? [...textPart, ...valueParts] : [{ text: value }]
195
205
  },
196
206
  outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
197
207
  taskType: googleOptions == null ? void 0 : googleOptions.taskType