@langchain/google-genai
Advanced tools
Comparing version 0.0.18 to 0.0.19
@@ -11,2 +11,3 @@ import type { z } from "zod"; | ||
} | ||
export declare function removeAdditionalProperties(obj: Record<string, any>): GenerativeAIJsonSchema; | ||
export declare function zodToGenerativeAIParameters(zodObj: z.ZodType<any>): GenerativeAIFunctionDeclarationSchema; |
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { zodToJsonSchema } from "zod-to-json-schema"; | ||
function removeAdditionalProperties(schema) { | ||
const updatedSchema = { ...schema }; | ||
if (Object.hasOwn(updatedSchema, "additionalProperties")) { | ||
delete updatedSchema.additionalProperties; | ||
export function removeAdditionalProperties( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
obj) { | ||
if (typeof obj === "object" && obj !== null) { | ||
const newObj = { ...obj }; | ||
if ("additionalProperties" in newObj && | ||
typeof newObj.additionalProperties === "boolean") { | ||
delete newObj.additionalProperties; | ||
} | ||
for (const key in newObj) { | ||
if (key in newObj) { | ||
if (Array.isArray(newObj[key])) { | ||
newObj[key] = newObj[key].map(removeAdditionalProperties); | ||
} | ||
else if (typeof newObj[key] === "object" && newObj[key] !== null) { | ||
newObj[key] = removeAdditionalProperties(newObj[key]); | ||
} | ||
} | ||
} | ||
return newObj; | ||
} | ||
if (updatedSchema.properties) { | ||
const keys = Object.keys(updatedSchema.properties); | ||
removeProperties(updatedSchema.properties, keys, 0); | ||
} | ||
return updatedSchema; | ||
return obj; | ||
} | ||
function removeProperties(properties, keys, index) { | ||
if (index >= keys.length || !properties) { | ||
return; | ||
} | ||
const key = keys[index]; | ||
// eslint-disable-next-line no-param-reassign | ||
properties[key] = removeAdditionalProperties(properties[key]); | ||
removeProperties(properties, keys, index + 1); | ||
} | ||
export function zodToGenerativeAIParameters( | ||
@@ -24,0 +27,0 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any |
{ | ||
"name": "@langchain/google-genai", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "Sample integration for LangChain.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93649
2203