@langchain/google-genai 0.0.18 → 0.0.19
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.
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.zodToGenerativeAIParameters = void 0;
|
|
4
|
+
exports.zodToGenerativeAIParameters = exports.removeAdditionalProperties = void 0;
|
|
5
5
|
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
6
|
-
function removeAdditionalProperties(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
function removeAdditionalProperties(
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
obj) {
|
|
9
|
+
if (typeof obj === "object" && obj !== null) {
|
|
10
|
+
const newObj = { ...obj };
|
|
11
|
+
if ("additionalProperties" in newObj &&
|
|
12
|
+
typeof newObj.additionalProperties === "boolean") {
|
|
13
|
+
delete newObj.additionalProperties;
|
|
14
|
+
}
|
|
15
|
+
for (const key in newObj) {
|
|
16
|
+
if (key in newObj) {
|
|
17
|
+
if (Array.isArray(newObj[key])) {
|
|
18
|
+
newObj[key] = newObj[key].map(removeAdditionalProperties);
|
|
19
|
+
}
|
|
20
|
+
else if (typeof newObj[key] === "object" && newObj[key] !== null) {
|
|
21
|
+
newObj[key] = removeAdditionalProperties(newObj[key]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return newObj;
|
|
20
26
|
}
|
|
21
|
-
|
|
22
|
-
// eslint-disable-next-line no-param-reassign
|
|
23
|
-
properties[key] = removeAdditionalProperties(properties[key]);
|
|
24
|
-
removeProperties(properties, keys, index + 1);
|
|
27
|
+
return obj;
|
|
25
28
|
}
|
|
29
|
+
exports.removeAdditionalProperties = removeAdditionalProperties;
|
|
26
30
|
function zodToGenerativeAIParameters(
|
|
27
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
32
|
zodObj) {
|
|
@@ -8,4 +8,5 @@ export interface GenerativeAIJsonSchemaDirty extends GenerativeAIJsonSchema {
|
|
|
8
8
|
properties?: Record<string, GenerativeAIJsonSchemaDirty>;
|
|
9
9
|
additionalProperties?: boolean;
|
|
10
10
|
}
|
|
11
|
+
export declare function removeAdditionalProperties(obj: Record<string, any>): GenerativeAIJsonSchema;
|
|
11
12
|
export declare function zodToGenerativeAIParameters(zodObj: z.ZodType<any>): GenerativeAIFunctionDeclarationSchema;
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
3
|
-
function removeAdditionalProperties(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
export function removeAdditionalProperties(
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
obj) {
|
|
6
|
+
if (typeof obj === "object" && obj !== null) {
|
|
7
|
+
const newObj = { ...obj };
|
|
8
|
+
if ("additionalProperties" in newObj &&
|
|
9
|
+
typeof newObj.additionalProperties === "boolean") {
|
|
10
|
+
delete newObj.additionalProperties;
|
|
11
|
+
}
|
|
12
|
+
for (const key in newObj) {
|
|
13
|
+
if (key in newObj) {
|
|
14
|
+
if (Array.isArray(newObj[key])) {
|
|
15
|
+
newObj[key] = newObj[key].map(removeAdditionalProperties);
|
|
16
|
+
}
|
|
17
|
+
else if (typeof newObj[key] === "object" && newObj[key] !== null) {
|
|
18
|
+
newObj[key] = removeAdditionalProperties(newObj[key]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return newObj;
|
|
17
23
|
}
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line no-param-reassign
|
|
20
|
-
properties[key] = removeAdditionalProperties(properties[key]);
|
|
21
|
-
removeProperties(properties, keys, index + 1);
|
|
24
|
+
return obj;
|
|
22
25
|
}
|
|
23
26
|
export function zodToGenerativeAIParameters(
|
|
24
27
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|