UNPKG

dtamind-components

Version:

Apps integration for Dtamind. Contain Nodes and Credentials.

48 lines 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.removeAdditionalProperties = removeAdditionalProperties; exports.schemaToGenerativeAIParameters = schemaToGenerativeAIParameters; exports.jsonSchemaToGeminiParameters = jsonSchemaToGeminiParameters; const types_1 = require("@langchain/core/utils/types"); const json_schema_1 = require("@langchain/core/utils/json_schema"); function removeAdditionalProperties(obj) { if (typeof obj === 'object' && obj !== null) { const newObj = { ...obj }; if ('additionalProperties' in newObj) { delete newObj.additionalProperties; } if ('$schema' in newObj) { delete newObj.$schema; } if ('strict' in newObj) { delete newObj.strict; } 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; } return obj; } function schemaToGenerativeAIParameters(schema) { // GenerativeAI doesn't accept either the $schema or additionalProperties // attributes, so we need to explicitly remove them. const jsonSchema = removeAdditionalProperties((0, types_1.isInteropZodSchema)(schema) ? (0, json_schema_1.toJsonSchema)(schema) : schema); const { _schema, ...rest } = jsonSchema; return rest; } function jsonSchemaToGeminiParameters(schema) { // Gemini doesn't accept either the $schema or additionalProperties // attributes, so we need to explicitly remove them. const jsonSchema = removeAdditionalProperties(schema); const { _schema, ...rest } = jsonSchema; return rest; } //# sourceMappingURL=zod_to_genai_parameters.js.map