@ai-sdk/google 3.0.47 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 3.0.48
4
+
5
+ ### Patch Changes
6
+
7
+ - 35c46d1: feat(provider/google): support multimodal content parts in embedding provider options
8
+
3
9
  ## 3.0.47
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -186,6 +186,14 @@ type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | (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?: ({
190
+ text: string;
191
+ } | {
192
+ inlineData: {
193
+ mimeType: string;
194
+ data: string;
195
+ };
196
+ })[] | undefined;
189
197
  }>;
190
198
  type GoogleEmbeddingModelOptions = InferSchema<typeof googleEmbeddingModelOptions>;
191
199
 
package/dist/index.d.ts CHANGED
@@ -186,6 +186,14 @@ type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | (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?: ({
190
+ text: string;
191
+ } | {
192
+ inlineData: {
193
+ mimeType: string;
194
+ data: string;
195
+ };
196
+ })[] | undefined;
189
197
  }>;
190
198
  type GoogleEmbeddingModelOptions = InferSchema<typeof googleEmbeddingModelOptions>;
191
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.47" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.48" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -59,6 +59,15 @@ var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
59
59
  // src/google-generative-ai-embedding-options.ts
60
60
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
61
61
  var import_v42 = require("zod/v4");
62
+ var googleEmbeddingContentPartSchema = import_v42.z.union([
63
+ import_v42.z.object({ text: import_v42.z.string() }),
64
+ import_v42.z.object({
65
+ inlineData: import_v42.z.object({
66
+ mimeType: import_v42.z.string(),
67
+ data: import_v42.z.string()
68
+ })
69
+ })
70
+ ]);
62
71
  var googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
63
72
  () => (0, import_provider_utils2.zodSchema)(
64
73
  import_v42.z.object({
@@ -88,7 +97,13 @@ var googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
88
97
  "QUESTION_ANSWERING",
89
98
  "FACT_VERIFICATION",
90
99
  "CODE_RETRIEVAL_QUERY"
91
- ]).optional()
100
+ ]).optional(),
101
+ /**
102
+ * Optional. Multimodal content parts for embedding non-text content
103
+ * (images, video, PDF, audio). When provided, these parts are used
104
+ * instead of the text values in the embedding request.
105
+ */
106
+ content: import_v42.z.array(googleEmbeddingContentPartSchema).min(1).optional()
92
107
  })
93
108
  )
94
109
  );
@@ -111,6 +126,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
111
126
  abortSignal,
112
127
  providerOptions
113
128
  }) {
129
+ var _a;
114
130
  const googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
115
131
  provider: "google",
116
132
  providerOptions,
@@ -128,7 +144,10 @@ var GoogleGenerativeAIEmbeddingModel = class {
128
144
  await (0, import_provider_utils3.resolve)(this.config.headers),
129
145
  headers
130
146
  );
147
+ const multimodalContent = (_a = googleOptions == null ? void 0 : googleOptions.content) != null ? _a : [];
131
148
  if (values.length === 1) {
149
+ const textPart = values[0] ? [{ text: values[0] }] : [];
150
+ const parts = multimodalContent.length > 0 ? [...textPart, ...multimodalContent] : [{ text: values[0] }];
132
151
  const {
133
152
  responseHeaders: responseHeaders2,
134
153
  value: response2,
@@ -139,7 +158,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
139
158
  body: {
140
159
  model: `models/${this.modelId}`,
141
160
  content: {
142
- parts: [{ text: values[0] }]
161
+ parts
143
162
  },
144
163
  outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
145
164
  taskType: googleOptions == null ? void 0 : googleOptions.taskType
@@ -166,12 +185,18 @@ var GoogleGenerativeAIEmbeddingModel = class {
166
185
  url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
167
186
  headers: mergedHeaders,
168
187
  body: {
169
- requests: values.map((value) => ({
170
- model: `models/${this.modelId}`,
171
- content: { role: "user", parts: [{ text: value }] },
172
- outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
173
- taskType: googleOptions == null ? void 0 : googleOptions.taskType
174
- }))
188
+ requests: values.map((value) => {
189
+ const textPart = value ? [{ text: value }] : [];
190
+ return {
191
+ model: `models/${this.modelId}`,
192
+ content: {
193
+ role: "user",
194
+ parts: multimodalContent.length > 0 ? [...textPart, ...multimodalContent] : [{ text: value }]
195
+ },
196
+ outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
197
+ taskType: googleOptions == null ? void 0 : googleOptions.taskType
198
+ };
199
+ })
175
200
  },
176
201
  failedResponseHandler: googleFailedResponseHandler,
177
202
  successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(