@langchain/google-common 2.1.22 → 2.1.24
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.
- package/CHANGELOG.md +15 -0
- package/dist/chat_models.cjs +20 -36
- package/dist/chat_models.cjs.map +1 -1
- package/dist/chat_models.d.cts +3 -2
- package/dist/chat_models.d.cts.map +1 -1
- package/dist/chat_models.d.ts +4 -3
- package/dist/chat_models.d.ts.map +1 -1
- package/dist/chat_models.js +20 -36
- package/dist/chat_models.js.map +1 -1
- package/dist/llms.cjs +1 -1
- package/dist/llms.js +1 -1
- package/dist/output_parsers.d.ts +1 -1
- package/dist/utils/anthropic.cjs +4 -1
- package/dist/utils/anthropic.cjs.map +1 -1
- package/dist/utils/anthropic.js +4 -1
- package/dist/utils/anthropic.js.map +1 -1
- package/dist/utils/zod_to_gemini_parameters.cjs +2 -1
- package/dist/utils/zod_to_gemini_parameters.cjs.map +1 -1
- package/dist/utils/zod_to_gemini_parameters.d.cts +2 -1
- package/dist/utils/zod_to_gemini_parameters.d.cts.map +1 -1
- package/dist/utils/zod_to_gemini_parameters.d.ts +2 -1
- package/dist/utils/zod_to_gemini_parameters.d.ts.map +1 -1
- package/dist/utils/zod_to_gemini_parameters.js +2 -1
- package/dist/utils/zod_to_gemini_parameters.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod_to_gemini_parameters.js","names":[],"sources":["../../src/utils/zod_to_gemini_parameters.ts"],"sourcesContent":["import {\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 GeminiFunctionSchema,\n GeminiJsonSchema,\n GeminiJsonSchemaDirty,\n} from \"../types.js\";\n\nexport function adjustObjectType(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any> {\n if (!Array.isArray(obj.type)) {\n return obj;\n }\n\n const len = obj.type.length;\n const nullIndex = obj.type.indexOf(\"null\");\n if (len === 2 && nullIndex >= 0) {\n // There are only two values set for the type, and one of them is \"null\".\n // Set the type to the other one and set nullable to true.\n const typeIndex = nullIndex === 0 ? 1 : 0;\n obj.type = obj.type[typeIndex];\n obj.nullable = true;\n } else if (len === 1 && nullIndex === 0) {\n // This is nullable only without a type, which doesn't\n // make sense for Gemini\n throw new Error(\"zod_to_gemini_parameters: Gemini cannot handle null type\");\n } else if (len === 1) {\n // Although an array, it has only one value.\n // So set it to the string to match what Gemini expects.\n obj.type = obj?.type[0];\n } else {\n // Anything else could be a union type, so reject it.\n throw new Error(\n \"zod_to_gemini_parameters: Gemini cannot handle union types\"\n );\n }\n return obj;\n}\n\nexport function removeAdditionalProperties(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n): GeminiJsonSchema {\n if (typeof obj === \"object\" && obj !== null) {\n const newObj = { ...obj };\n\n if (\"additionalProperties\" in newObj) {\n delete newObj.additionalProperties;\n }\n\n // Check for union types (anyOf, oneOf) which Gemini doesn't support\n if (\"anyOf\" in newObj || \"oneOf\" in newObj) {\n const unionTypes = newObj.anyOf || newObj.oneOf;\n\n // Check if this is a nullable union (e.g., T | null)\n // This is a 2-element array where one element is {type: \"null\"}\n if (Array.isArray(unionTypes) && unionTypes.length === 2) {\n const nullIndex = unionTypes.findIndex((t) => t.type === \"null\");\n\n if (nullIndex >= 0) {\n // This is a nullable union - extract the non-null type\n const nonNullType = unionTypes[nullIndex === 0 ? 1 : 0];\n delete newObj.anyOf;\n delete newObj.oneOf;\n // Merge the non-null type properties and add nullable: true\n for (const key in nonNullType) {\n if (key in nonNullType) {\n newObj[key] = nonNullType[key];\n }\n }\n newObj.nullable = true;\n } else {\n // Not a simple nullable union - reject it\n throw new Error(\n \"zod_to_gemini_parameters: Gemini cannot handle union types (discriminatedUnion, anyOf, oneOf). \" +\n \"Consider using a flat object structure with optional fields instead.\"\n );\n }\n } else {\n // Not a simple nullable union - reject it\n throw new Error(\n \"zod_to_gemini_parameters: Gemini cannot handle union types (discriminatedUnion, anyOf, oneOf). \" +\n \"Consider using a flat object structure with optional fields instead.\"\n );\n }\n }\n\n // Convert exclusiveMinimum (from .positive()) to minimum\n if (\"exclusiveMinimum\" in newObj && newObj.exclusiveMinimum === 0) {\n // Convert .positive() to .min(0.01)\n newObj.minimum = 0.01;\n delete newObj.exclusiveMinimum;\n } else if (\"exclusiveMinimum\" in newObj) {\n // Convert other exclusiveMinimum to minimum with a small increment\n newObj.minimum = newObj.exclusiveMinimum + 0.00001;\n delete newObj.exclusiveMinimum;\n }\n\n adjustObjectType(newObj);\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 GeminiJsonSchema;\n }\n\n return obj as GeminiJsonSchema;\n}\n\nexport function schemaToGeminiParameters<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n>(schema
|
|
1
|
+
{"version":3,"file":"zod_to_gemini_parameters.js","names":[],"sources":["../../src/utils/zod_to_gemini_parameters.ts"],"sourcesContent":["import {\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 GeminiFunctionSchema,\n GeminiJsonSchema,\n GeminiJsonSchemaDirty,\n} from \"../types.js\";\nimport {\n isSerializableSchema,\n SerializableSchema,\n} from \"@langchain/core/utils/standard_schema\";\n\nexport function adjustObjectType(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any> {\n if (!Array.isArray(obj.type)) {\n return obj;\n }\n\n const len = obj.type.length;\n const nullIndex = obj.type.indexOf(\"null\");\n if (len === 2 && nullIndex >= 0) {\n // There are only two values set for the type, and one of them is \"null\".\n // Set the type to the other one and set nullable to true.\n const typeIndex = nullIndex === 0 ? 1 : 0;\n obj.type = obj.type[typeIndex];\n obj.nullable = true;\n } else if (len === 1 && nullIndex === 0) {\n // This is nullable only without a type, which doesn't\n // make sense for Gemini\n throw new Error(\"zod_to_gemini_parameters: Gemini cannot handle null type\");\n } else if (len === 1) {\n // Although an array, it has only one value.\n // So set it to the string to match what Gemini expects.\n obj.type = obj?.type[0];\n } else {\n // Anything else could be a union type, so reject it.\n throw new Error(\n \"zod_to_gemini_parameters: Gemini cannot handle union types\"\n );\n }\n return obj;\n}\n\nexport function removeAdditionalProperties(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n): GeminiJsonSchema {\n if (typeof obj === \"object\" && obj !== null) {\n const newObj = { ...obj };\n\n if (\"additionalProperties\" in newObj) {\n delete newObj.additionalProperties;\n }\n\n // Check for union types (anyOf, oneOf) which Gemini doesn't support\n if (\"anyOf\" in newObj || \"oneOf\" in newObj) {\n const unionTypes = newObj.anyOf || newObj.oneOf;\n\n // Check if this is a nullable union (e.g., T | null)\n // This is a 2-element array where one element is {type: \"null\"}\n if (Array.isArray(unionTypes) && unionTypes.length === 2) {\n const nullIndex = unionTypes.findIndex((t) => t.type === \"null\");\n\n if (nullIndex >= 0) {\n // This is a nullable union - extract the non-null type\n const nonNullType = unionTypes[nullIndex === 0 ? 1 : 0];\n delete newObj.anyOf;\n delete newObj.oneOf;\n // Merge the non-null type properties and add nullable: true\n for (const key in nonNullType) {\n if (key in nonNullType) {\n newObj[key] = nonNullType[key];\n }\n }\n newObj.nullable = true;\n } else {\n // Not a simple nullable union - reject it\n throw new Error(\n \"zod_to_gemini_parameters: Gemini cannot handle union types (discriminatedUnion, anyOf, oneOf). \" +\n \"Consider using a flat object structure with optional fields instead.\"\n );\n }\n } else {\n // Not a simple nullable union - reject it\n throw new Error(\n \"zod_to_gemini_parameters: Gemini cannot handle union types (discriminatedUnion, anyOf, oneOf). \" +\n \"Consider using a flat object structure with optional fields instead.\"\n );\n }\n }\n\n // Convert exclusiveMinimum (from .positive()) to minimum\n if (\"exclusiveMinimum\" in newObj && newObj.exclusiveMinimum === 0) {\n // Convert .positive() to .min(0.01)\n newObj.minimum = 0.01;\n delete newObj.exclusiveMinimum;\n } else if (\"exclusiveMinimum\" in newObj) {\n // Convert other exclusiveMinimum to minimum with a small increment\n newObj.minimum = newObj.exclusiveMinimum + 0.00001;\n delete newObj.exclusiveMinimum;\n }\n\n adjustObjectType(newObj);\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 GeminiJsonSchema;\n }\n\n return obj as GeminiJsonSchema;\n}\n\nexport function schemaToGeminiParameters<\n // eslint-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): GeminiFunctionSchema {\n // Gemini doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n // Zod sometimes also makes an array of type (because of .nullish()),\n // which needs cleaning up.\n const jsonSchema = removeAdditionalProperties(\n isInteropZodSchema(schema) || isSerializableSchema(schema)\n ? toJsonSchema(schema)\n : schema\n );\n const { $schema, ...rest } = jsonSchema;\n return rest;\n}\n\nexport function jsonSchemaToGeminiParameters(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>\n): GeminiFunctionSchema {\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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UAAO,OAAO;;AAGhB,mBAAiB,OAAO;AAExB,OAAK,MAAM,OAAO,OAChB,KAAI,OAAO,QACT;OAAI,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,yBAId,QAIsB;CAUtB,MAAM,EAAE,SAAS,GAAG,SALD,2BACjB,mBAAmB,OAAO,IAAI,qBAAqB,OAAO,GACtD,aAAa,OAAO,GACpB,OACL;AAED,QAAO;;AAGT,SAAgB,6BAEd,QACsB;CAMtB,MAAM,EAAE,SAAS,GAAG,SAHD,2BACjB,OACD;AAGD,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/google-common",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.24",
|
|
4
4
|
"description": "Core types and classes for Google services.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"uuid": "^10.0.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@langchain/core": "^1.1.
|
|
20
|
+
"@langchain/core": "^1.1.30"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@jest/globals": "^30.2.0",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"ts-jest": "^29.4.6",
|
|
35
35
|
"typescript": "~5.8.3",
|
|
36
36
|
"zod": "^3.25.76",
|
|
37
|
-
"@langchain/core": "^1.1.
|
|
38
|
-
"@langchain/
|
|
39
|
-
"@langchain/
|
|
37
|
+
"@langchain/core": "^1.1.30",
|
|
38
|
+
"@langchain/eslint": "0.1.1",
|
|
39
|
+
"@langchain/tsconfig": "0.0.1"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
|
|
129
129
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
|
|
130
130
|
"test:single": "NODE_OPTIONS=--experimental-vm-modules pnpm run jest --config jest.config.cjs --testTimeout 100000",
|
|
131
|
-
"test:int": "NODE_OPTIONS=--experimental-vm-modules jest --
|
|
131
|
+
"test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPatterns=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
|
|
132
132
|
"format": "prettier --write \"src\"",
|
|
133
133
|
"format:check": "prettier --check \"src\"",
|
|
134
134
|
"typegen": "pnpm run typegen:profiles",
|