@ai-sdk/google 2.0.59 → 2.0.61
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 +14 -0
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +35 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +4 -4
- package/dist/internal/index.d.ts +4 -4
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 2.0.61
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3399b61: feat(provider/google): support multimodal content parts in embedding provider options
|
|
8
|
+
|
|
9
|
+
## 2.0.60
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 3f0102b: fix(provider/google): make `segment` optional in `groundingSupports` schema
|
|
14
|
+
|
|
15
|
+
Backport of #12002. When using image search grounding, the Google API returns `groundingSupports` entries without a `segment` field, causing schema validation to fail with "Invalid JSON response".
|
|
16
|
+
|
|
3
17
|
## 2.0.59
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -111,11 +111,11 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
111
111
|
} | null | undefined;
|
|
112
112
|
}[] | null | undefined;
|
|
113
113
|
groundingSupports?: {
|
|
114
|
-
segment
|
|
114
|
+
segment?: {
|
|
115
115
|
startIndex?: number | null | undefined;
|
|
116
116
|
endIndex?: number | null | undefined;
|
|
117
117
|
text?: string | null | undefined;
|
|
118
|
-
};
|
|
118
|
+
} | null | undefined;
|
|
119
119
|
segment_text?: string | null | undefined;
|
|
120
120
|
groundingChunkIndices?: number[] | null | undefined;
|
|
121
121
|
supportChunkIndices?: number[] | null | undefined;
|
|
@@ -184,6 +184,14 @@ type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'text-embeddi
|
|
|
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?: ({
|
|
188
|
+
text: string;
|
|
189
|
+
} | {
|
|
190
|
+
inlineData: {
|
|
191
|
+
mimeType: string;
|
|
192
|
+
data: string;
|
|
193
|
+
};
|
|
194
|
+
})[] | undefined;
|
|
187
195
|
}>;
|
|
188
196
|
type GoogleGenerativeAIEmbeddingProviderOptions = InferValidator<typeof googleGenerativeAIEmbeddingProviderOptions>;
|
|
189
197
|
|
package/dist/index.d.ts
CHANGED
|
@@ -111,11 +111,11 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
111
111
|
} | null | undefined;
|
|
112
112
|
}[] | null | undefined;
|
|
113
113
|
groundingSupports?: {
|
|
114
|
-
segment
|
|
114
|
+
segment?: {
|
|
115
115
|
startIndex?: number | null | undefined;
|
|
116
116
|
endIndex?: number | null | undefined;
|
|
117
117
|
text?: string | null | undefined;
|
|
118
|
-
};
|
|
118
|
+
} | null | undefined;
|
|
119
119
|
segment_text?: string | null | undefined;
|
|
120
120
|
groundingChunkIndices?: number[] | null | undefined;
|
|
121
121
|
supportChunkIndices?: number[] | null | undefined;
|
|
@@ -184,6 +184,14 @@ type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'text-embeddi
|
|
|
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?: ({
|
|
188
|
+
text: string;
|
|
189
|
+
} | {
|
|
190
|
+
inlineData: {
|
|
191
|
+
mimeType: string;
|
|
192
|
+
data: string;
|
|
193
|
+
};
|
|
194
|
+
})[] | undefined;
|
|
187
195
|
}>;
|
|
188
196
|
type GoogleGenerativeAIEmbeddingProviderOptions = InferValidator<typeof googleGenerativeAIEmbeddingProviderOptions>;
|
|
189
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.61" : "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 googleGenerativeAIEmbeddingProviderOptions = (0, import_provider_utils2.lazySchema)(
|
|
63
72
|
() => (0, import_provider_utils2.zodSchema)(
|
|
64
73
|
import_v42.z.object({
|
|
@@ -88,7 +97,13 @@ var googleGenerativeAIEmbeddingProviderOptions = (0, import_provider_utils2.lazy
|
|
|
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 merged
|
|
104
|
+
* with 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
|
|
161
|
+
parts
|
|
143
162
|
},
|
|
144
163
|
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
145
164
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
@@ -165,12 +184,18 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
165
184
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
166
185
|
headers: mergedHeaders,
|
|
167
186
|
body: {
|
|
168
|
-
requests: values.map((value) =>
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
187
|
+
requests: values.map((value) => {
|
|
188
|
+
const textPart = value ? [{ text: value }] : [];
|
|
189
|
+
return {
|
|
190
|
+
model: `models/${this.modelId}`,
|
|
191
|
+
content: {
|
|
192
|
+
role: "user",
|
|
193
|
+
parts: multimodalContent.length > 0 ? [...textPart, ...multimodalContent] : [{ text: value }]
|
|
194
|
+
},
|
|
195
|
+
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
196
|
+
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
197
|
+
};
|
|
198
|
+
})
|
|
174
199
|
},
|
|
175
200
|
failedResponseHandler: googleFailedResponseHandler,
|
|
176
201
|
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
|
|
@@ -1471,7 +1496,7 @@ var getGroundingMetadataSchema = () => import_v45.z.object({
|
|
|
1471
1496
|
startIndex: import_v45.z.number().nullish(),
|
|
1472
1497
|
endIndex: import_v45.z.number().nullish(),
|
|
1473
1498
|
text: import_v45.z.string().nullish()
|
|
1474
|
-
}),
|
|
1499
|
+
}).nullish(),
|
|
1475
1500
|
segment_text: import_v45.z.string().nullish(),
|
|
1476
1501
|
groundingChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
|
|
1477
1502
|
supportChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
|