@ai-sdk/google 2.0.41 → 2.0.43
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +32 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -27
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +4 -2
- package/dist/internal/index.d.ts +4 -2
- package/dist/internal/index.js +31 -26
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +31 -26
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 2.0.43
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7b2c30f: Fixed Zod validation error when using `google.tools.fileSearch()`. The Google File Search API returns `fileSearchStore` instead of `uri` in `retrievedContext`. Updated `extractSources()` function to handle both the old format (Google Search with `uri`) and new format (File Search with `fileSearchStore`), maintaining backward compatibility while preventing validation errors. Also fixed title handling to use `undefined` for URL sources and `'Unknown Document'` for document sources.
|
|
8
|
+
|
|
9
|
+
## 2.0.42
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- b60216b: Change streamText loop to merge file part processing into main parts loop
|
|
14
|
+
|
|
3
15
|
## 2.0.41
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -85,9 +85,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
85
85
|
title?: string | null | undefined;
|
|
86
86
|
} | null | undefined;
|
|
87
87
|
retrievedContext?: {
|
|
88
|
-
uri
|
|
88
|
+
uri?: string | null | undefined;
|
|
89
89
|
title?: string | null | undefined;
|
|
90
90
|
text?: string | null | undefined;
|
|
91
|
+
fileSearchStore?: string | null | undefined;
|
|
91
92
|
} | null | undefined;
|
|
92
93
|
}[] | null | undefined;
|
|
93
94
|
groundingSupports?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -85,9 +85,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
85
85
|
title?: string | null | undefined;
|
|
86
86
|
} | null | undefined;
|
|
87
87
|
retrievedContext?: {
|
|
88
|
-
uri
|
|
88
|
+
uri?: string | null | undefined;
|
|
89
89
|
title?: string | null | undefined;
|
|
90
90
|
text?: string | null | undefined;
|
|
91
|
+
fileSearchStore?: string | null | undefined;
|
|
91
92
|
} | null | undefined;
|
|
92
93
|
}[] | null | undefined;
|
|
93
94
|
groundingSupports?: {
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
30
30
|
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "2.0.
|
|
33
|
+
var VERSION = true ? "2.0.43" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -236,14 +236,16 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
|
236
236
|
}
|
|
237
237
|
if (type) {
|
|
238
238
|
if (Array.isArray(type)) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
const hasNull = type.includes("null");
|
|
240
|
+
const nonNullTypes = type.filter((t) => t !== "null");
|
|
241
|
+
if (nonNullTypes.length === 0) {
|
|
242
|
+
result.type = "null";
|
|
242
243
|
} else {
|
|
243
|
-
result.
|
|
244
|
+
result.anyOf = nonNullTypes.map((t) => ({ type: t }));
|
|
245
|
+
if (hasNull) {
|
|
246
|
+
result.nullable = true;
|
|
247
|
+
}
|
|
244
248
|
}
|
|
245
|
-
} else if (type === "null") {
|
|
246
|
-
result.type = "null";
|
|
247
249
|
} else {
|
|
248
250
|
result.type = type;
|
|
249
251
|
}
|
|
@@ -718,7 +720,7 @@ function prepareTools({
|
|
|
718
720
|
}
|
|
719
721
|
if (toolChoice == null) {
|
|
720
722
|
return {
|
|
721
|
-
tools: { functionDeclarations },
|
|
723
|
+
tools: [{ functionDeclarations }],
|
|
722
724
|
toolConfig: void 0,
|
|
723
725
|
toolWarnings
|
|
724
726
|
};
|
|
@@ -727,25 +729,25 @@ function prepareTools({
|
|
|
727
729
|
switch (type) {
|
|
728
730
|
case "auto":
|
|
729
731
|
return {
|
|
730
|
-
tools: { functionDeclarations },
|
|
732
|
+
tools: [{ functionDeclarations }],
|
|
731
733
|
toolConfig: { functionCallingConfig: { mode: "AUTO" } },
|
|
732
734
|
toolWarnings
|
|
733
735
|
};
|
|
734
736
|
case "none":
|
|
735
737
|
return {
|
|
736
|
-
tools: { functionDeclarations },
|
|
738
|
+
tools: [{ functionDeclarations }],
|
|
737
739
|
toolConfig: { functionCallingConfig: { mode: "NONE" } },
|
|
738
740
|
toolWarnings
|
|
739
741
|
};
|
|
740
742
|
case "required":
|
|
741
743
|
return {
|
|
742
|
-
tools: { functionDeclarations },
|
|
744
|
+
tools: [{ functionDeclarations }],
|
|
743
745
|
toolConfig: { functionCallingConfig: { mode: "ANY" } },
|
|
744
746
|
toolWarnings
|
|
745
747
|
};
|
|
746
748
|
case "tool":
|
|
747
749
|
return {
|
|
748
|
-
tools: { functionDeclarations },
|
|
750
|
+
tools: [{ functionDeclarations }],
|
|
749
751
|
toolConfig: {
|
|
750
752
|
functionCallingConfig: {
|
|
751
753
|
mode: "ANY",
|
|
@@ -1164,11 +1166,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1164
1166
|
} : void 0
|
|
1165
1167
|
});
|
|
1166
1168
|
}
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
const inlineDataParts = getInlineDataParts(content.parts);
|
|
1170
|
-
if (inlineDataParts != null) {
|
|
1171
|
-
for (const part of inlineDataParts) {
|
|
1169
|
+
} else if ("inlineData" in part) {
|
|
1172
1170
|
controller.enqueue({
|
|
1173
1171
|
type: "file",
|
|
1174
1172
|
mediaType: part.inlineData.mimeType,
|
|
@@ -1270,16 +1268,11 @@ function getToolCallsFromParts({
|
|
|
1270
1268
|
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
1271
1269
|
}));
|
|
1272
1270
|
}
|
|
1273
|
-
function getInlineDataParts(parts) {
|
|
1274
|
-
return parts == null ? void 0 : parts.filter(
|
|
1275
|
-
(part) => "inlineData" in part
|
|
1276
|
-
);
|
|
1277
|
-
}
|
|
1278
1271
|
function extractSources({
|
|
1279
1272
|
groundingMetadata,
|
|
1280
1273
|
generateId: generateId3
|
|
1281
1274
|
}) {
|
|
1282
|
-
var _a, _b, _c;
|
|
1275
|
+
var _a, _b, _c, _d;
|
|
1283
1276
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
1284
1277
|
return void 0;
|
|
1285
1278
|
}
|
|
@@ -1295,7 +1288,8 @@ function extractSources({
|
|
|
1295
1288
|
});
|
|
1296
1289
|
} else if (chunk.retrievedContext != null) {
|
|
1297
1290
|
const uri = chunk.retrievedContext.uri;
|
|
1298
|
-
|
|
1291
|
+
const fileSearchStore = chunk.retrievedContext.fileSearchStore;
|
|
1292
|
+
if (uri && (uri.startsWith("http://") || uri.startsWith("https://"))) {
|
|
1299
1293
|
sources.push({
|
|
1300
1294
|
type: "source",
|
|
1301
1295
|
sourceType: "url",
|
|
@@ -1303,7 +1297,7 @@ function extractSources({
|
|
|
1303
1297
|
url: uri,
|
|
1304
1298
|
title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
|
|
1305
1299
|
});
|
|
1306
|
-
} else {
|
|
1300
|
+
} else if (uri) {
|
|
1307
1301
|
const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
|
|
1308
1302
|
let mediaType = "application/octet-stream";
|
|
1309
1303
|
let filename = void 0;
|
|
@@ -1333,6 +1327,16 @@ function extractSources({
|
|
|
1333
1327
|
title,
|
|
1334
1328
|
filename
|
|
1335
1329
|
});
|
|
1330
|
+
} else if (fileSearchStore) {
|
|
1331
|
+
const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
|
|
1332
|
+
sources.push({
|
|
1333
|
+
type: "source",
|
|
1334
|
+
sourceType: "document",
|
|
1335
|
+
id: generateId3(),
|
|
1336
|
+
mediaType: "application/octet-stream",
|
|
1337
|
+
title,
|
|
1338
|
+
filename: fileSearchStore.split("/").pop()
|
|
1339
|
+
});
|
|
1336
1340
|
}
|
|
1337
1341
|
}
|
|
1338
1342
|
}
|
|
@@ -1346,9 +1350,10 @@ var getGroundingMetadataSchema = () => import_v45.z.object({
|
|
|
1346
1350
|
import_v45.z.object({
|
|
1347
1351
|
web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string().nullish() }).nullish(),
|
|
1348
1352
|
retrievedContext: import_v45.z.object({
|
|
1349
|
-
uri: import_v45.z.string(),
|
|
1353
|
+
uri: import_v45.z.string().nullish(),
|
|
1350
1354
|
title: import_v45.z.string().nullish(),
|
|
1351
|
-
text: import_v45.z.string().nullish()
|
|
1355
|
+
text: import_v45.z.string().nullish(),
|
|
1356
|
+
fileSearchStore: import_v45.z.string().nullish()
|
|
1352
1357
|
}).nullish()
|
|
1353
1358
|
})
|
|
1354
1359
|
).nullish(),
|