@langchain/openai 0.5.11 → 0.5.13

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.
@@ -3,7 +3,7 @@ import { LangSmithParams, type BaseChatModelParams } from "@langchain/core/langu
3
3
  import { BaseLanguageModelInput } from "@langchain/core/language_models/base";
4
4
  import { BaseMessage } from "@langchain/core/messages";
5
5
  import { Runnable } from "@langchain/core/runnables";
6
- import { z } from "zod";
6
+ import { InteropZodType } from "@langchain/core/utils/types";
7
7
  import { ChatOpenAI, ChatOpenAIStructuredOutputMethodOptions } from "../chat_models.js";
8
8
  import { AzureOpenAIInput, OpenAIChatInput, OpenAICoreRequestOptions } from "../types.js";
9
9
  export type { AzureOpenAIInput };
@@ -444,12 +444,12 @@ export declare class AzureChatOpenAI extends ChatOpenAI {
444
444
  getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
445
445
  protected _getClientOptions(options: OpenAICoreRequestOptions | undefined): OpenAICoreRequestOptions;
446
446
  toJSON(): any;
447
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
448
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
447
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
448
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
449
449
  raw: BaseMessage;
450
450
  parsed: RunOutput;
451
451
  }>;
452
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
452
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
453
453
  raw: BaseMessage;
454
454
  parsed: RunOutput;
455
455
  }>;
@@ -1,6 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.ChatOpenAI = exports._convertMessagesToOpenAIParams = exports.messageToOpenAIRole = void 0;
27
+ const z4 = __importStar(require("zod/v4/core"));
4
28
  const openai_1 = require("openai");
5
29
  const messages_1 = require("@langchain/core/messages");
6
30
  const outputs_1 = require("@langchain/core/outputs");
@@ -10,8 +34,9 @@ const base_1 = require("@langchain/core/language_models/base");
10
34
  const runnables_1 = require("@langchain/core/runnables");
11
35
  const output_parsers_1 = require("@langchain/core/output_parsers");
12
36
  const openai_tools_1 = require("@langchain/core/output_parsers/openai_tools");
13
- const zod_to_json_schema_1 = require("zod-to-json-schema");
14
37
  const zod_1 = require("openai/helpers/zod");
38
+ const types_1 = require("@langchain/core/utils/types");
39
+ const json_schema_1 = require("@langchain/core/utils/json_schema");
15
40
  const azure_js_1 = require("./utils/azure.cjs");
16
41
  const openai_js_1 = require("./utils/openai.cjs");
17
42
  const openai_format_fndef_js_1 = require("./utils/openai-format-fndef.cjs");
@@ -300,7 +325,7 @@ function _convertMessagesToOpenAIResponsesParams(messages, model, zdrEnabled) {
300
325
  return {
301
326
  type: "function_call_output",
302
327
  call_id: toolMessage.tool_call_id,
303
- id: toolMessage.id,
328
+ id: toolMessage.id?.startsWith("fc_") ? toolMessage.id : undefined,
304
329
  output: typeof toolMessage.content !== "string"
305
330
  ? JSON.stringify(toolMessage.content)
306
331
  : toolMessage.content,
@@ -1587,8 +1612,8 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
1587
1612
  if (resFormat &&
1588
1613
  resFormat.type === "json_schema" &&
1589
1614
  resFormat.json_schema.schema &&
1590
- isZodSchema(resFormat.json_schema.schema)) {
1591
- return (0, zod_1.zodResponseFormat)(resFormat.json_schema.schema, resFormat.json_schema.name, {
1615
+ (0, types_1.isInteropZodSchema)(resFormat.json_schema.schema)) {
1616
+ return interopZodResponseFormat(resFormat.json_schema.schema, resFormat.json_schema.name, {
1592
1617
  description: resFormat.json_schema.description,
1593
1618
  });
1594
1619
  }
@@ -2461,7 +2486,7 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
2461
2486
  llm = this.withConfig({
2462
2487
  response_format: { type: "json_object" },
2463
2488
  });
2464
- if (isZodSchema(schema)) {
2489
+ if ((0, types_1.isInteropZodSchema)(schema)) {
2465
2490
  outputParser = output_parsers_1.StructuredOutputParser.fromZodSchema(schema);
2466
2491
  }
2467
2492
  else {
@@ -2474,13 +2499,13 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
2474
2499
  type: "json_schema",
2475
2500
  json_schema: {
2476
2501
  name: name ?? "extract",
2477
- description: schema.description,
2502
+ description: (0, types_1.getSchemaDescription)(schema),
2478
2503
  schema,
2479
2504
  strict: config?.strict,
2480
2505
  },
2481
2506
  },
2482
2507
  });
2483
- if (isZodSchema(schema)) {
2508
+ if ((0, types_1.isInteropZodSchema)(schema)) {
2484
2509
  const altParser = output_parsers_1.StructuredOutputParser.fromZodSchema(schema);
2485
2510
  outputParser = runnables_1.RunnableLambda.from((aiMessage) => {
2486
2511
  if ("parsed" in aiMessage.additional_kwargs) {
@@ -2496,8 +2521,8 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
2496
2521
  else {
2497
2522
  let functionName = name ?? "extract";
2498
2523
  // Is function calling
2499
- if (isZodSchema(schema)) {
2500
- const asJsonSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(schema);
2524
+ if ((0, types_1.isInteropZodSchema)(schema)) {
2525
+ const asJsonSchema = (0, json_schema_1.toJsonSchema)(schema);
2501
2526
  llm = this.withConfig({
2502
2527
  tools: [
2503
2528
  {
@@ -2579,12 +2604,6 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
2579
2604
  }
2580
2605
  }
2581
2606
  exports.ChatOpenAI = ChatOpenAI;
2582
- function isZodSchema(
2583
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2584
- input) {
2585
- // Check for a characteristic method of Zod schemas
2586
- return typeof input?.parse === "function";
2587
- }
2588
2607
  function isStructuredOutputMethodParams(x
2589
2608
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2590
2609
  ) {
@@ -2593,3 +2612,49 @@ function isStructuredOutputMethodParams(x
2593
2612
  typeof x.schema ===
2594
2613
  "object");
2595
2614
  }
2615
+ // inlined from openai/lib/parser.ts
2616
+ function makeParseableResponseFormat(response_format, parser) {
2617
+ const obj = { ...response_format };
2618
+ Object.defineProperties(obj, {
2619
+ $brand: {
2620
+ value: "auto-parseable-response-format",
2621
+ enumerable: false,
2622
+ },
2623
+ $parseRaw: {
2624
+ value: parser,
2625
+ enumerable: false,
2626
+ },
2627
+ });
2628
+ return obj;
2629
+ }
2630
+ function interopZodResponseFormat(zodSchema, name, props) {
2631
+ if ((0, types_1.isZodSchemaV3)(zodSchema)) {
2632
+ return (0, zod_1.zodResponseFormat)(zodSchema, name, props);
2633
+ }
2634
+ if ((0, types_1.isZodSchemaV4)(zodSchema)) {
2635
+ return makeParseableResponseFormat({
2636
+ type: "json_schema",
2637
+ json_schema: {
2638
+ ...props,
2639
+ name,
2640
+ strict: true,
2641
+ schema: z4.toJSONSchema(zodSchema, {
2642
+ cycles: "ref",
2643
+ reused: "ref",
2644
+ override(ctx) {
2645
+ ctx.jsonSchema.title = name; // equivalent to `name` property
2646
+ // TODO: implement `nullableStrategy` patch-fix (zod doesn't support openApi3 json schema target)
2647
+ // TODO: implement `openaiStrictMode` patch-fix (where optional properties without `nullable` are not supported)
2648
+ },
2649
+ /// property equivalents from native `zodResponseFormat` fn
2650
+ // openaiStrictMode: true,
2651
+ // name,
2652
+ // nameStrategy: 'duplicate-ref',
2653
+ // $refStrategy: 'extract-to-root',
2654
+ // nullableStrategy: 'property',
2655
+ }),
2656
+ },
2657
+ }, (content) => z4.parse(zodSchema, JSON.parse(content)));
2658
+ }
2659
+ throw new Error("Unsupported schema response format");
2660
+ }
@@ -4,8 +4,8 @@ import { AIMessageChunk, type BaseMessage, ChatMessageChunk, FunctionMessageChun
4
4
  import { ChatGenerationChunk, type ChatResult } from "@langchain/core/outputs";
5
5
  import { BaseChatModel, type BindToolsInput, type LangSmithParams, type BaseChatModelParams } from "@langchain/core/language_models/chat_models";
6
6
  import { type BaseFunctionCallOptions, type BaseLanguageModelInput, type StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
7
- import { z } from "zod";
8
7
  import { Runnable } from "@langchain/core/runnables";
8
+ import { InteropZodType } from "@langchain/core/utils/types";
9
9
  import { type OpenAICallOptions, type OpenAIChatInput, type OpenAICoreRequestOptions, type ChatOpenAIResponseFormat } from "./types.js";
10
10
  import { OpenAIToolChoice } from "./utils/openai.js";
11
11
  export type { OpenAICallOptions, OpenAIChatInput };
@@ -846,12 +846,12 @@ export declare class ChatOpenAI<CallOptions extends ChatOpenAICallOptions = Chat
846
846
  _llmType(): string;
847
847
  /** @ignore */
848
848
  _combineLLMOutput(...llmOutputs: OpenAILLMOutput[]): OpenAILLMOutput;
849
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
850
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
849
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
850
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
851
851
  raw: BaseMessage;
852
852
  parsed: RunOutput;
853
853
  }>;
854
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
854
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: ChatOpenAIStructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
855
855
  raw: BaseMessage;
856
856
  parsed: RunOutput;
857
857
  }>;
@@ -1,3 +1,4 @@
1
+ import * as z4 from "zod/v4/core";
1
2
  import { OpenAI as OpenAIClient } from "openai";
2
3
  import { AIMessage, AIMessageChunk, ChatMessage, ChatMessageChunk, FunctionMessageChunk, HumanMessageChunk, SystemMessageChunk, ToolMessageChunk, isAIMessage, parseBase64DataUrl, parseMimeType, convertToProviderContentBlock, isDataContentBlock, } from "@langchain/core/messages";
3
4
  import { ChatGenerationChunk, } from "@langchain/core/outputs";
@@ -7,8 +8,9 @@ import { isOpenAITool, } from "@langchain/core/language_models/base";
7
8
  import { RunnableLambda, RunnablePassthrough, RunnableSequence, } from "@langchain/core/runnables";
8
9
  import { JsonOutputParser, StructuredOutputParser, } from "@langchain/core/output_parsers";
9
10
  import { JsonOutputKeyToolsParser, convertLangChainToolCallToOpenAI, makeInvalidToolCall, parseToolCall, } from "@langchain/core/output_parsers/openai_tools";
10
- import { zodToJsonSchema } from "zod-to-json-schema";
11
11
  import { zodResponseFormat } from "openai/helpers/zod";
12
+ import { getSchemaDescription, isInteropZodSchema, isZodSchemaV3, isZodSchemaV4, } from "@langchain/core/utils/types";
13
+ import { toJsonSchema } from "@langchain/core/utils/json_schema";
12
14
  import { getEndpoint } from "./utils/azure.js";
13
15
  import { formatToOpenAIToolChoice, wrapOpenAIClientError, } from "./utils/openai.js";
14
16
  import { formatFunctionDefinitions, } from "./utils/openai-format-fndef.js";
@@ -295,7 +297,7 @@ function _convertMessagesToOpenAIResponsesParams(messages, model, zdrEnabled) {
295
297
  return {
296
298
  type: "function_call_output",
297
299
  call_id: toolMessage.tool_call_id,
298
- id: toolMessage.id,
300
+ id: toolMessage.id?.startsWith("fc_") ? toolMessage.id : undefined,
299
301
  output: typeof toolMessage.content !== "string"
300
302
  ? JSON.stringify(toolMessage.content)
301
303
  : toolMessage.content,
@@ -1582,8 +1584,8 @@ export class ChatOpenAI extends BaseChatModel {
1582
1584
  if (resFormat &&
1583
1585
  resFormat.type === "json_schema" &&
1584
1586
  resFormat.json_schema.schema &&
1585
- isZodSchema(resFormat.json_schema.schema)) {
1586
- return zodResponseFormat(resFormat.json_schema.schema, resFormat.json_schema.name, {
1587
+ isInteropZodSchema(resFormat.json_schema.schema)) {
1588
+ return interopZodResponseFormat(resFormat.json_schema.schema, resFormat.json_schema.name, {
1587
1589
  description: resFormat.json_schema.description,
1588
1590
  });
1589
1591
  }
@@ -2456,7 +2458,7 @@ export class ChatOpenAI extends BaseChatModel {
2456
2458
  llm = this.withConfig({
2457
2459
  response_format: { type: "json_object" },
2458
2460
  });
2459
- if (isZodSchema(schema)) {
2461
+ if (isInteropZodSchema(schema)) {
2460
2462
  outputParser = StructuredOutputParser.fromZodSchema(schema);
2461
2463
  }
2462
2464
  else {
@@ -2469,13 +2471,13 @@ export class ChatOpenAI extends BaseChatModel {
2469
2471
  type: "json_schema",
2470
2472
  json_schema: {
2471
2473
  name: name ?? "extract",
2472
- description: schema.description,
2474
+ description: getSchemaDescription(schema),
2473
2475
  schema,
2474
2476
  strict: config?.strict,
2475
2477
  },
2476
2478
  },
2477
2479
  });
2478
- if (isZodSchema(schema)) {
2480
+ if (isInteropZodSchema(schema)) {
2479
2481
  const altParser = StructuredOutputParser.fromZodSchema(schema);
2480
2482
  outputParser = RunnableLambda.from((aiMessage) => {
2481
2483
  if ("parsed" in aiMessage.additional_kwargs) {
@@ -2491,8 +2493,8 @@ export class ChatOpenAI extends BaseChatModel {
2491
2493
  else {
2492
2494
  let functionName = name ?? "extract";
2493
2495
  // Is function calling
2494
- if (isZodSchema(schema)) {
2495
- const asJsonSchema = zodToJsonSchema(schema);
2496
+ if (isInteropZodSchema(schema)) {
2497
+ const asJsonSchema = toJsonSchema(schema);
2496
2498
  llm = this.withConfig({
2497
2499
  tools: [
2498
2500
  {
@@ -2573,12 +2575,6 @@ export class ChatOpenAI extends BaseChatModel {
2573
2575
  return RunnableSequence.from([{ raw: llm }, parsedWithFallback]);
2574
2576
  }
2575
2577
  }
2576
- function isZodSchema(
2577
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2578
- input) {
2579
- // Check for a characteristic method of Zod schemas
2580
- return typeof input?.parse === "function";
2581
- }
2582
2578
  function isStructuredOutputMethodParams(x
2583
2579
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2584
2580
  ) {
@@ -2587,3 +2583,49 @@ function isStructuredOutputMethodParams(x
2587
2583
  typeof x.schema ===
2588
2584
  "object");
2589
2585
  }
2586
+ // inlined from openai/lib/parser.ts
2587
+ function makeParseableResponseFormat(response_format, parser) {
2588
+ const obj = { ...response_format };
2589
+ Object.defineProperties(obj, {
2590
+ $brand: {
2591
+ value: "auto-parseable-response-format",
2592
+ enumerable: false,
2593
+ },
2594
+ $parseRaw: {
2595
+ value: parser,
2596
+ enumerable: false,
2597
+ },
2598
+ });
2599
+ return obj;
2600
+ }
2601
+ function interopZodResponseFormat(zodSchema, name, props) {
2602
+ if (isZodSchemaV3(zodSchema)) {
2603
+ return zodResponseFormat(zodSchema, name, props);
2604
+ }
2605
+ if (isZodSchemaV4(zodSchema)) {
2606
+ return makeParseableResponseFormat({
2607
+ type: "json_schema",
2608
+ json_schema: {
2609
+ ...props,
2610
+ name,
2611
+ strict: true,
2612
+ schema: z4.toJSONSchema(zodSchema, {
2613
+ cycles: "ref",
2614
+ reused: "ref",
2615
+ override(ctx) {
2616
+ ctx.jsonSchema.title = name; // equivalent to `name` property
2617
+ // TODO: implement `nullableStrategy` patch-fix (zod doesn't support openApi3 json schema target)
2618
+ // TODO: implement `openaiStrictMode` patch-fix (where optional properties without `nullable` are not supported)
2619
+ },
2620
+ /// property equivalents from native `zodResponseFormat` fn
2621
+ // openaiStrictMode: true,
2622
+ // name,
2623
+ // nameStrategy: 'duplicate-ref',
2624
+ // $refStrategy: 'extract-to-root',
2625
+ // nullableStrategy: 'property',
2626
+ }),
2627
+ },
2628
+ }, (content) => z4.parse(zodSchema, JSON.parse(content)));
2629
+ }
2630
+ throw new Error("Unsupported schema response format");
2631
+ }
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { RequestOptions as _OpenAICoreRequestOptions } from "openai/core";
3
3
  import type { ResponseFormatText, ResponseFormatJSONObject, ResponseFormatJSONSchema } from "openai/resources/shared";
4
4
  import { TiktokenModel } from "js-tiktoken/lite";
5
5
  import type { BaseLanguageModelCallOptions } from "@langchain/core/language_models/base";
6
- import type { z } from "zod";
6
+ import { InteropZodObject } from "@langchain/core/utils/types";
7
7
  export type { TiktokenModel };
8
8
  export declare interface OpenAIBaseInput {
9
9
  /** Sampling temperature to use */
@@ -218,7 +218,7 @@ type ChatOpenAIResponseFormatJSONSchema = Omit<ResponseFormatJSONSchema, "json_s
218
218
  * The schema for the response format, described as a JSON Schema object
219
219
  * or a Zod object.
220
220
  */
221
- schema: Record<string, any> | z.ZodObject<any, any, any, any>;
221
+ schema: Record<string, any> | InteropZodObject;
222
222
  };
223
223
  };
224
224
  /**
@@ -5,8 +5,8 @@ const openai_1 = require("openai");
5
5
  const function_calling_1 = require("@langchain/core/utils/function_calling");
6
6
  Object.defineProperty(exports, "formatToOpenAIFunction", { enumerable: true, get: function () { return function_calling_1.convertToOpenAIFunction; } });
7
7
  Object.defineProperty(exports, "formatToOpenAITool", { enumerable: true, get: function () { return function_calling_1.convertToOpenAITool; } });
8
- const zod_to_json_schema_1 = require("zod-to-json-schema");
9
8
  const types_1 = require("@langchain/core/utils/types");
9
+ const json_schema_1 = require("@langchain/core/utils/json_schema");
10
10
  const errors_js_1 = require("./errors.cjs");
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
  function wrapOpenAIClientError(e) {
@@ -43,8 +43,8 @@ function formatToOpenAIAssistantTool(tool) {
43
43
  function: {
44
44
  name: tool.name,
45
45
  description: tool.description,
46
- parameters: (0, types_1.isZodSchema)(tool.schema)
47
- ? (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema)
46
+ parameters: (0, types_1.isInteropZodSchema)(tool.schema)
47
+ ? (0, json_schema_1.toJsonSchema)(tool.schema)
48
48
  : tool.schema,
49
49
  },
50
50
  };
@@ -1,7 +1,7 @@
1
1
  import { APIConnectionTimeoutError, APIUserAbortError, } from "openai";
2
2
  import { convertToOpenAIFunction, convertToOpenAITool, } from "@langchain/core/utils/function_calling";
3
- import { zodToJsonSchema } from "zod-to-json-schema";
4
- import { isZodSchema } from "@langchain/core/utils/types";
3
+ import { isInteropZodSchema } from "@langchain/core/utils/types";
4
+ import { toJsonSchema } from "@langchain/core/utils/json_schema";
5
5
  import { addLangChainErrorFields } from "./errors.js";
6
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
7
  export function wrapOpenAIClientError(e) {
@@ -38,8 +38,8 @@ export function formatToOpenAIAssistantTool(tool) {
38
38
  function: {
39
39
  name: tool.name,
40
40
  description: tool.description,
41
- parameters: isZodSchema(tool.schema)
42
- ? zodToJsonSchema(tool.schema)
41
+ parameters: isInteropZodSchema(tool.schema)
42
+ ? toJsonSchema(tool.schema)
43
43
  : tool.schema,
44
44
  },
45
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/openai",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "description": "OpenAI integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -37,11 +37,10 @@
37
37
  "dependencies": {
38
38
  "js-tiktoken": "^1.0.12",
39
39
  "openai": "^4.96.0",
40
- "zod": "^3.22.4",
41
- "zod-to-json-schema": "^3.22.3"
40
+ "zod": "3.25.32"
42
41
  },
43
42
  "peerDependencies": {
44
- "@langchain/core": ">=0.3.48 <0.4.0"
43
+ "@langchain/core": ">=0.3.58 <0.4.0"
45
44
  },
46
45
  "devDependencies": {
47
46
  "@azure/identity": "^4.2.1",
@@ -55,7 +54,7 @@
55
54
  "eslint": "^8.33.0",
56
55
  "eslint-config-airbnb-base": "^15.0.0",
57
56
  "eslint-config-prettier": "^8.6.0",
58
- "eslint-plugin-import": "^2.27.5",
57
+ "eslint-plugin-import": "^2.31.0",
59
58
  "eslint-plugin-jest": "^27.6.0",
60
59
  "eslint-plugin-no-instanceof": "^1.0.1",
61
60
  "eslint-plugin-prettier": "^4.2.1",