@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(schema) {
7
- const updatedSchema = { ...schema };
8
- if (Object.hasOwn(updatedSchema, "additionalProperties")) {
9
- delete updatedSchema.additionalProperties;
10
- }
11
- if (updatedSchema.properties) {
12
- const keys = Object.keys(updatedSchema.properties);
13
- removeProperties(updatedSchema.properties, keys, 0);
14
- }
15
- return updatedSchema;
16
- }
17
- function removeProperties(properties, keys, index) {
18
- if (index >= keys.length || !properties) {
19
- return;
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
- const key = keys[index];
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(schema) {
4
- const updatedSchema = { ...schema };
5
- if (Object.hasOwn(updatedSchema, "additionalProperties")) {
6
- delete updatedSchema.additionalProperties;
7
- }
8
- if (updatedSchema.properties) {
9
- const keys = Object.keys(updatedSchema.properties);
10
- removeProperties(updatedSchema.properties, keys, 0);
11
- }
12
- return updatedSchema;
13
- }
14
- function removeProperties(properties, keys, index) {
15
- if (index >= keys.length || !properties) {
16
- return;
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
- const key = keys[index];
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/google-genai",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Sample integration for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {