@langchain/google-genai 2.1.31 → 2.2.0

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 +1 @@
1
- {"version":3,"file":"zod_to_genai_parameters.cjs","names":[],"sources":["../../src/utils/zod_to_genai_parameters.ts"],"sourcesContent":["import {\n type FunctionDeclarationSchema as GenerativeAIFunctionDeclarationSchema,\n type SchemaType as FunctionDeclarationSchemaType,\n} from \"@google/generative-ai\";\nimport {\n InteropZodType,\n isInteropZodSchema,\n} from \"@langchain/core/utils/types\";\nimport {\n type JsonSchema7Type,\n toJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n isSerializableSchema,\n SerializableSchema,\n} from \"@langchain/core/utils/standard_schema\";\n\nexport interface GenerativeAIJsonSchema extends Record<string, unknown> {\n properties?: Record<string, GenerativeAIJsonSchema>;\n type: FunctionDeclarationSchemaType;\n}\n\nexport interface GenerativeAIJsonSchemaDirty extends GenerativeAIJsonSchema {\n properties?: Record<string, GenerativeAIJsonSchemaDirty>;\n additionalProperties?: boolean;\n}\n\nexport function removeAdditionalProperties(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n): GenerativeAIJsonSchema {\n if (typeof obj === \"object\" && obj !== null) {\n const newObj = { ...obj };\n\n if (\"additionalProperties\" in newObj) {\n delete newObj.additionalProperties;\n }\n if (\"$schema\" in newObj) {\n delete newObj.$schema;\n }\n if (\"strict\" in newObj) {\n delete newObj.strict;\n }\n\n for (const key in newObj) {\n if (key in newObj) {\n if (Array.isArray(newObj[key])) {\n newObj[key] = newObj[key].map(removeAdditionalProperties);\n } else if (typeof newObj[key] === \"object\" && newObj[key] !== null) {\n newObj[key] = removeAdditionalProperties(newObj[key]);\n }\n }\n }\n\n return newObj as GenerativeAIJsonSchema;\n }\n\n return obj as GenerativeAIJsonSchema;\n}\n\nexport function schemaToGenerativeAIParameters<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n>(\n schema:\n | SerializableSchema<RunOutput>\n | InteropZodType<RunOutput>\n | JsonSchema7Type\n): GenerativeAIFunctionDeclarationSchema {\n // GenerativeAI doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n isInteropZodSchema(schema) || isSerializableSchema(schema)\n ? toJsonSchema(schema)\n : schema\n );\n const { $schema, ...rest } = jsonSchema;\n return rest as GenerativeAIFunctionDeclarationSchema;\n}\n\nexport function jsonSchemaToGeminiParameters(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>\n): GenerativeAIFunctionDeclarationSchema {\n // Gemini doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n schema as GenerativeAIJsonSchemaDirty\n );\n const { $schema, ...rest } = jsonSchema;\n\n return rest as GenerativeAIFunctionDeclarationSchema;\n}\n"],"mappings":";;;;AA2BA,SAAgB,2BAEd,KACwB;AACxB,KAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC3C,MAAM,SAAS,EAAE,GAAG,KAAK;AAEzB,MAAI,0BAA0B,OAC5B,QAAO,OAAO;AAEhB,MAAI,aAAa,OACf,QAAO,OAAO;AAEhB,MAAI,YAAY,OACd,QAAO,OAAO;AAGhB,OAAK,MAAM,OAAO,OAChB,KAAI,OAAO;OACL,MAAM,QAAQ,OAAO,KAAK,CAC5B,QAAO,OAAO,OAAO,KAAK,IAAI,2BAA2B;YAChD,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS,KAC5D,QAAO,OAAO,2BAA2B,OAAO,KAAK;;AAK3D,SAAO;;AAGT,QAAO;;AAGT,SAAgB,+BAId,QAIuC;CAQvC,MAAM,EAAE,SAAS,GAAG,SALD,4BAAA,GAAA,4BAAA,oBACE,OAAO,KAAA,GAAA,sCAAA,sBAAyB,OAAO,IAAA,GAAA,kCAAA,cACzC,OAAO,GACpB,OACL;AAED,QAAO;;AAGT,SAAgB,6BAEd,QACuC;CAMvC,MAAM,EAAE,SAAS,GAAG,SAHD,2BACjB,OACD;AAGD,QAAO"}
1
+ {"version":3,"file":"zod_to_genai_parameters.cjs","names":[],"sources":["../../src/utils/zod_to_genai_parameters.ts"],"sourcesContent":["import {\n type FunctionDeclarationSchema as GenerativeAIFunctionDeclarationSchema,\n type SchemaType as FunctionDeclarationSchemaType,\n} from \"@google/generative-ai\";\nimport {\n InteropZodType,\n isInteropZodSchema,\n} from \"@langchain/core/utils/types\";\nimport {\n type JsonSchema7Type,\n toJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n isSerializableSchema,\n SerializableSchema,\n} from \"@langchain/core/utils/standard_schema\";\n\nexport interface GenerativeAIJsonSchema extends Record<string, unknown> {\n properties?: Record<string, GenerativeAIJsonSchema>;\n type: FunctionDeclarationSchemaType;\n}\n\nexport interface GenerativeAIJsonSchemaDirty extends GenerativeAIJsonSchema {\n properties?: Record<string, GenerativeAIJsonSchemaDirty>;\n additionalProperties?: boolean;\n}\n\nexport function removeAdditionalProperties(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n): GenerativeAIJsonSchema {\n if (typeof obj === \"object\" && obj !== null) {\n const newObj = { ...obj };\n\n if (\"additionalProperties\" in newObj) {\n delete newObj.additionalProperties;\n }\n if (\"$schema\" in newObj) {\n delete newObj.$schema;\n }\n if (\"strict\" in newObj) {\n delete newObj.strict;\n }\n\n for (const key in newObj) {\n if (key in newObj) {\n if (Array.isArray(newObj[key])) {\n newObj[key] = newObj[key].map(removeAdditionalProperties);\n } else if (typeof newObj[key] === \"object\" && newObj[key] !== null) {\n newObj[key] = removeAdditionalProperties(newObj[key]);\n }\n }\n }\n\n return newObj as GenerativeAIJsonSchema;\n }\n\n return obj as GenerativeAIJsonSchema;\n}\n\nexport function schemaToGenerativeAIParameters<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n>(\n schema:\n | SerializableSchema<RunOutput>\n | InteropZodType<RunOutput>\n | JsonSchema7Type\n): GenerativeAIFunctionDeclarationSchema {\n // GenerativeAI doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n isInteropZodSchema(schema) || isSerializableSchema(schema)\n ? toJsonSchema(schema)\n : schema\n );\n const { $schema, ...rest } = jsonSchema;\n return rest as GenerativeAIFunctionDeclarationSchema;\n}\n\nexport function jsonSchemaToGeminiParameters(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>\n): GenerativeAIFunctionDeclarationSchema {\n // Gemini doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n schema as GenerativeAIJsonSchemaDirty\n );\n const { $schema, ...rest } = jsonSchema;\n\n return rest as GenerativeAIFunctionDeclarationSchema;\n}\n"],"mappings":";;;;AA2BA,SAAgB,2BAEd,KACwB;AACxB,KAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC3C,MAAM,SAAS,EAAE,GAAG,KAAK;AAEzB,MAAI,0BAA0B,OAC5B,QAAO,OAAO;AAEhB,MAAI,aAAa,OACf,QAAO,OAAO;AAEhB,MAAI,YAAY,OACd,QAAO,OAAO;AAGhB,OAAK,MAAM,OAAO,OAChB,KAAI,OAAO;OACL,MAAM,QAAQ,OAAO,KAAK,CAC5B,QAAO,OAAO,OAAO,KAAK,IAAI,2BAA2B;YAChD,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS,KAC5D,QAAO,OAAO,2BAA2B,OAAO,KAAK;;AAK3D,SAAO;;AAGT,QAAO;;AAGT,SAAgB,+BAId,QAIuC;CAQvC,MAAM,EAAE,SAAS,GAAG,SALD,4BAAA,GAAA,4BAAA,oBACE,OAAO,KAAA,GAAA,sCAAA,sBAAyB,OAAO,IAAA,GAAA,kCAAA,cACzC,OAAO,GACpB,OAEiC;AACvC,QAAO;;AAGT,SAAgB,6BAEd,QACuC;CAMvC,MAAM,EAAE,SAAS,GAAG,SAHD,2BACjB,OAEqC;AAEvC,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"zod_to_genai_parameters.js","names":[],"sources":["../../src/utils/zod_to_genai_parameters.ts"],"sourcesContent":["import {\n type FunctionDeclarationSchema as GenerativeAIFunctionDeclarationSchema,\n type SchemaType as FunctionDeclarationSchemaType,\n} from \"@google/generative-ai\";\nimport {\n InteropZodType,\n isInteropZodSchema,\n} from \"@langchain/core/utils/types\";\nimport {\n type JsonSchema7Type,\n toJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n isSerializableSchema,\n SerializableSchema,\n} from \"@langchain/core/utils/standard_schema\";\n\nexport interface GenerativeAIJsonSchema extends Record<string, unknown> {\n properties?: Record<string, GenerativeAIJsonSchema>;\n type: FunctionDeclarationSchemaType;\n}\n\nexport interface GenerativeAIJsonSchemaDirty extends GenerativeAIJsonSchema {\n properties?: Record<string, GenerativeAIJsonSchemaDirty>;\n additionalProperties?: boolean;\n}\n\nexport function removeAdditionalProperties(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n): GenerativeAIJsonSchema {\n if (typeof obj === \"object\" && obj !== null) {\n const newObj = { ...obj };\n\n if (\"additionalProperties\" in newObj) {\n delete newObj.additionalProperties;\n }\n if (\"$schema\" in newObj) {\n delete newObj.$schema;\n }\n if (\"strict\" in newObj) {\n delete newObj.strict;\n }\n\n for (const key in newObj) {\n if (key in newObj) {\n if (Array.isArray(newObj[key])) {\n newObj[key] = newObj[key].map(removeAdditionalProperties);\n } else if (typeof newObj[key] === \"object\" && newObj[key] !== null) {\n newObj[key] = removeAdditionalProperties(newObj[key]);\n }\n }\n }\n\n return newObj as GenerativeAIJsonSchema;\n }\n\n return obj as GenerativeAIJsonSchema;\n}\n\nexport function schemaToGenerativeAIParameters<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n>(\n schema:\n | SerializableSchema<RunOutput>\n | InteropZodType<RunOutput>\n | JsonSchema7Type\n): GenerativeAIFunctionDeclarationSchema {\n // GenerativeAI doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n isInteropZodSchema(schema) || isSerializableSchema(schema)\n ? toJsonSchema(schema)\n : schema\n );\n const { $schema, ...rest } = jsonSchema;\n return rest as GenerativeAIFunctionDeclarationSchema;\n}\n\nexport function jsonSchemaToGeminiParameters(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>\n): GenerativeAIFunctionDeclarationSchema {\n // Gemini doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n schema as GenerativeAIJsonSchemaDirty\n );\n const { $schema, ...rest } = jsonSchema;\n\n return rest as GenerativeAIFunctionDeclarationSchema;\n}\n"],"mappings":";;;;AA2BA,SAAgB,2BAEd,KACwB;AACxB,KAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC3C,MAAM,SAAS,EAAE,GAAG,KAAK;AAEzB,MAAI,0BAA0B,OAC5B,QAAO,OAAO;AAEhB,MAAI,aAAa,OACf,QAAO,OAAO;AAEhB,MAAI,YAAY,OACd,QAAO,OAAO;AAGhB,OAAK,MAAM,OAAO,OAChB,KAAI,OAAO;OACL,MAAM,QAAQ,OAAO,KAAK,CAC5B,QAAO,OAAO,OAAO,KAAK,IAAI,2BAA2B;YAChD,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS,KAC5D,QAAO,OAAO,2BAA2B,OAAO,KAAK;;AAK3D,SAAO;;AAGT,QAAO;;AAGT,SAAgB,+BAId,QAIuC;CAQvC,MAAM,EAAE,SAAS,GAAG,SALD,2BACjB,mBAAmB,OAAO,IAAI,qBAAqB,OAAO,GACtD,aAAa,OAAO,GACpB,OACL;AAED,QAAO;;AAGT,SAAgB,6BAEd,QACuC;CAMvC,MAAM,EAAE,SAAS,GAAG,SAHD,2BACjB,OACD;AAGD,QAAO"}
1
+ {"version":3,"file":"zod_to_genai_parameters.js","names":[],"sources":["../../src/utils/zod_to_genai_parameters.ts"],"sourcesContent":["import {\n type FunctionDeclarationSchema as GenerativeAIFunctionDeclarationSchema,\n type SchemaType as FunctionDeclarationSchemaType,\n} from \"@google/generative-ai\";\nimport {\n InteropZodType,\n isInteropZodSchema,\n} from \"@langchain/core/utils/types\";\nimport {\n type JsonSchema7Type,\n toJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n isSerializableSchema,\n SerializableSchema,\n} from \"@langchain/core/utils/standard_schema\";\n\nexport interface GenerativeAIJsonSchema extends Record<string, unknown> {\n properties?: Record<string, GenerativeAIJsonSchema>;\n type: FunctionDeclarationSchemaType;\n}\n\nexport interface GenerativeAIJsonSchemaDirty extends GenerativeAIJsonSchema {\n properties?: Record<string, GenerativeAIJsonSchemaDirty>;\n additionalProperties?: boolean;\n}\n\nexport function removeAdditionalProperties(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n): GenerativeAIJsonSchema {\n if (typeof obj === \"object\" && obj !== null) {\n const newObj = { ...obj };\n\n if (\"additionalProperties\" in newObj) {\n delete newObj.additionalProperties;\n }\n if (\"$schema\" in newObj) {\n delete newObj.$schema;\n }\n if (\"strict\" in newObj) {\n delete newObj.strict;\n }\n\n for (const key in newObj) {\n if (key in newObj) {\n if (Array.isArray(newObj[key])) {\n newObj[key] = newObj[key].map(removeAdditionalProperties);\n } else if (typeof newObj[key] === \"object\" && newObj[key] !== null) {\n newObj[key] = removeAdditionalProperties(newObj[key]);\n }\n }\n }\n\n return newObj as GenerativeAIJsonSchema;\n }\n\n return obj as GenerativeAIJsonSchema;\n}\n\nexport function schemaToGenerativeAIParameters<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n>(\n schema:\n | SerializableSchema<RunOutput>\n | InteropZodType<RunOutput>\n | JsonSchema7Type\n): GenerativeAIFunctionDeclarationSchema {\n // GenerativeAI doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n isInteropZodSchema(schema) || isSerializableSchema(schema)\n ? toJsonSchema(schema)\n : schema\n );\n const { $schema, ...rest } = jsonSchema;\n return rest as GenerativeAIFunctionDeclarationSchema;\n}\n\nexport function jsonSchemaToGeminiParameters(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>\n): GenerativeAIFunctionDeclarationSchema {\n // Gemini doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n schema as GenerativeAIJsonSchemaDirty\n );\n const { $schema, ...rest } = jsonSchema;\n\n return rest as GenerativeAIFunctionDeclarationSchema;\n}\n"],"mappings":";;;;AA2BA,SAAgB,2BAEd,KACwB;AACxB,KAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC3C,MAAM,SAAS,EAAE,GAAG,KAAK;AAEzB,MAAI,0BAA0B,OAC5B,QAAO,OAAO;AAEhB,MAAI,aAAa,OACf,QAAO,OAAO;AAEhB,MAAI,YAAY,OACd,QAAO,OAAO;AAGhB,OAAK,MAAM,OAAO,OAChB,KAAI,OAAO;OACL,MAAM,QAAQ,OAAO,KAAK,CAC5B,QAAO,OAAO,OAAO,KAAK,IAAI,2BAA2B;YAChD,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS,KAC5D,QAAO,OAAO,2BAA2B,OAAO,KAAK;;AAK3D,SAAO;;AAGT,QAAO;;AAGT,SAAgB,+BAId,QAIuC;CAQvC,MAAM,EAAE,SAAS,GAAG,SALD,2BACjB,mBAAmB,OAAO,IAAI,qBAAqB,OAAO,GACtD,aAAa,OAAO,GACpB,OAEiC;AACvC,QAAO;;AAGT,SAAgB,6BAEd,QACuC;CAMvC,MAAM,EAAE,SAAS,GAAG,SAHD,2BACjB,OAEqC;AAEvC,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/google-genai",
3
- "version": "2.1.31",
3
+ "version": "2.2.0",
4
4
  "description": "Google Generative AI integration for LangChain.js",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -17,17 +17,17 @@
17
17
  "@google/generative-ai": "^0.24.1"
18
18
  },
19
19
  "peerDependencies": {
20
- "@langchain/core": "^1.1.47"
20
+ "@langchain/core": "^1.2.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@tsconfig/recommended": "^1.0.3",
24
24
  "dotenv": "^17.4.0",
25
25
  "dpdm": "^3.14.0",
26
26
  "hnswlib-node": "^3.0.0",
27
- "typescript": "~5.8.3",
28
- "vitest": "^4.1.2",
27
+ "typescript": "~6.0.3",
28
+ "vitest": "^4.1.8",
29
29
  "zod": "^3.25.76",
30
- "@langchain/core": "^1.1.47",
30
+ "@langchain/core": "^1.2.0",
31
31
  "@langchain/standard-tests": "0.0.23",
32
32
  "@langchain/tsconfig": "0.0.1"
33
33
  },