@langchain/google-common 0.2.10 → 0.2.11

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.
@@ -8,6 +8,7 @@ const messages_1 = require("@langchain/core/messages");
8
8
  const runnables_1 = require("@langchain/core/runnables");
9
9
  const openai_tools_1 = require("@langchain/core/output_parsers/openai_tools");
10
10
  const stream_1 = require("@langchain/core/utils/stream");
11
+ const types_1 = require("@langchain/core/utils/types");
11
12
  const common_js_1 = require("./utils/common.cjs");
12
13
  const connection_js_1 = require("./connection.cjs");
13
14
  const gemini_js_1 = require("./utils/gemini.cjs");
@@ -380,7 +381,7 @@ class ChatGoogleBase extends chat_models_1.BaseChatModel {
380
381
  let functionName = name ?? "extract";
381
382
  let outputParser;
382
383
  let tools;
383
- if (isZodSchema(schema)) {
384
+ if ((0, types_1.isInteropZodSchema)(schema)) {
384
385
  const jsonSchema = (0, zod_to_gemini_parameters_js_1.schemaToGeminiParameters)(schema);
385
386
  tools = [
386
387
  {
@@ -451,9 +452,3 @@ class ChatGoogleBase extends chat_models_1.BaseChatModel {
451
452
  }
452
453
  }
453
454
  exports.ChatGoogleBase = ChatGoogleBase;
454
- function isZodSchema(
455
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
456
- input) {
457
- // Check for a characteristic method of Zod schemas
458
- return typeof input?.parse === "function";
459
- }
@@ -4,9 +4,9 @@ import { BaseChatModel, LangSmithParams, type BaseChatModelParams } from "@langc
4
4
  import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
5
5
  import { AIMessageChunk } from "@langchain/core/messages";
6
6
  import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
7
- import type { z } from "zod";
8
7
  import { Runnable } from "@langchain/core/runnables";
9
8
  import { AsyncCaller } from "@langchain/core/utils/async_caller";
9
+ import { InteropZodType } from "@langchain/core/utils/types";
10
10
  import { GoogleAIBaseLLMInput, GoogleAIModelParams, GoogleAISafetySetting, GoogleConnectionParams, GooglePlatformType, GoogleAIBaseLanguageModelCallOptions, GoogleAIAPI, GoogleAIAPIParams, GoogleSearchToolSetting } from "./types.js";
11
11
  import { AbstractGoogleLLMConnection } from "./connection.js";
12
12
  import { GoogleAbstractedClient } from "./auth.js";
@@ -74,8 +74,8 @@ export declare abstract class ChatGoogleBase<AuthOptions> extends BaseChatModel<
74
74
  _streamResponseChunks(_messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
75
75
  /** @ignore */
76
76
  _combineLLMOutput(): never[];
77
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
78
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
77
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
78
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
79
79
  raw: BaseMessage;
80
80
  parsed: RunOutput;
81
81
  }>;
@@ -5,6 +5,7 @@ import { AIMessageChunk } from "@langchain/core/messages";
5
5
  import { RunnablePassthrough, RunnableSequence, } from "@langchain/core/runnables";
6
6
  import { JsonOutputKeyToolsParser } from "@langchain/core/output_parsers/openai_tools";
7
7
  import { concat } from "@langchain/core/utils/stream";
8
+ import { isInteropZodSchema, } from "@langchain/core/utils/types";
8
9
  import { convertToGeminiTools, copyAIModelParams, copyAndValidateModelParamsInto, } from "./utils/common.js";
9
10
  import { AbstractGoogleLLMConnection } from "./connection.js";
10
11
  import { DefaultGeminiSafetyHandler, getGeminiAPI } from "./utils/gemini.js";
@@ -376,7 +377,7 @@ export class ChatGoogleBase extends BaseChatModel {
376
377
  let functionName = name ?? "extract";
377
378
  let outputParser;
378
379
  let tools;
379
- if (isZodSchema(schema)) {
380
+ if (isInteropZodSchema(schema)) {
380
381
  const jsonSchema = schemaToGeminiParameters(schema);
381
382
  tools = [
382
383
  {
@@ -446,9 +447,3 @@ export class ChatGoogleBase extends BaseChatModel {
446
447
  });
447
448
  }
448
449
  }
449
- function isZodSchema(
450
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
451
- input) {
452
- // Check for a characteristic method of Zod schemas
453
- return typeof input?.parse === "function";
454
- }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.jsonSchemaToGeminiParameters = exports.schemaToGeminiParameters = exports.removeAdditionalProperties = void 0;
5
5
  const types_1 = require("@langchain/core/utils/types");
6
- const zod_to_json_schema_1 = require("zod-to-json-schema");
6
+ const json_schema_1 = require("@langchain/core/utils/json_schema");
7
7
  function removeAdditionalProperties(
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
9
  obj) {
@@ -57,7 +57,7 @@ function schemaToGeminiParameters(schema) {
57
57
  // attributes, so we need to explicitly remove them.
58
58
  // Zod sometimes also makes an array of type (because of .nullish()),
59
59
  // which needs cleaning up.
60
- const jsonSchema = removeAdditionalProperties((0, types_1.isZodSchema)(schema) ? (0, zod_to_json_schema_1.zodToJsonSchema)(schema) : schema);
60
+ const jsonSchema = removeAdditionalProperties((0, types_1.isInteropZodSchema)(schema) ? (0, json_schema_1.toJsonSchema)(schema) : schema);
61
61
  const { $schema, ...rest } = jsonSchema;
62
62
  return rest;
63
63
  }
@@ -1,6 +1,6 @@
1
- import type { z } from "zod";
2
- import { type JsonSchema7Type } from "zod-to-json-schema";
1
+ import { InteropZodType } from "@langchain/core/utils/types";
2
+ import { type JsonSchema7Type } from "@langchain/core/utils/json_schema";
3
3
  import { GeminiFunctionSchema, GeminiJsonSchema } from "../types.js";
4
4
  export declare function removeAdditionalProperties(obj: Record<string, any>): GeminiJsonSchema;
5
- export declare function schemaToGeminiParameters<RunOutput extends Record<string, any> = Record<string, any>>(schema: z.ZodType<RunOutput> | z.ZodEffects<z.ZodType<RunOutput>> | JsonSchema7Type): GeminiFunctionSchema;
5
+ export declare function schemaToGeminiParameters<RunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GeminiFunctionSchema;
6
6
  export declare function jsonSchemaToGeminiParameters(schema: Record<string, any>): GeminiFunctionSchema;
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import { isZodSchema } from "@langchain/core/utils/types";
3
- import { zodToJsonSchema } from "zod-to-json-schema";
2
+ import { isInteropZodSchema, } from "@langchain/core/utils/types";
3
+ import { toJsonSchema, } from "@langchain/core/utils/json_schema";
4
4
  export function removeAdditionalProperties(
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
6
  obj) {
@@ -53,7 +53,7 @@ export function schemaToGeminiParameters(schema) {
53
53
  // attributes, so we need to explicitly remove them.
54
54
  // Zod sometimes also makes an array of type (because of .nullish()),
55
55
  // which needs cleaning up.
56
- const jsonSchema = removeAdditionalProperties(isZodSchema(schema) ? zodToJsonSchema(schema) : schema);
56
+ const jsonSchema = removeAdditionalProperties(isInteropZodSchema(schema) ? toJsonSchema(schema) : schema);
57
57
  const { $schema, ...rest } = jsonSchema;
58
58
  return rest;
59
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/google-common",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "Core types and classes for Google services.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -32,15 +32,14 @@
32
32
  "author": "LangChain",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "uuid": "^10.0.0",
36
- "zod-to-json-schema": "^3.22.4"
35
+ "uuid": "^10.0.0"
37
36
  },
38
37
  "peerDependencies": {
39
- "@langchain/core": ">=0.3.55 <0.4.0"
38
+ "@langchain/core": ">=0.3.58 <0.4.0"
40
39
  },
41
40
  "devDependencies": {
42
41
  "@jest/globals": "^29.5.0",
43
- "@langchain/core": "0.3.57",
42
+ "@langchain/core": "workspace:*",
44
43
  "@langchain/scripts": ">=0.1.0 <0.2.0",
45
44
  "@swc/core": "^1.3.90",
46
45
  "@swc/jest": "^0.2.29",
@@ -138,4 +137,4 @@
138
137
  "experimental/utils/media_core.d.ts",
139
138
  "experimental/utils/media_core.d.cts"
140
139
  ]
141
- }
140
+ }