@langchain/openai 0.6.8 → 0.6.10

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.
@@ -273,6 +273,7 @@ class BaseChatOpenAI extends chat_models_1.BaseChatModel {
273
273
  "response_format",
274
274
  "seed",
275
275
  "reasoning",
276
+ "reasoning_effort",
276
277
  "service_tier",
277
278
  ];
278
279
  }
@@ -324,8 +325,9 @@ class BaseChatOpenAI extends chat_models_1.BaseChatModel {
324
325
  "disableStreaming",
325
326
  "zdrEnabled",
326
327
  "reasoning",
327
- "verbosity",
328
+ "reasoning_effort",
328
329
  "promptCacheKey",
330
+ "verbosity",
329
331
  ];
330
332
  }
331
333
  getLsParams(options) {
@@ -555,6 +557,15 @@ class BaseChatOpenAI extends chat_models_1.BaseChatModel {
555
557
  writable: true,
556
558
  value: void 0
557
559
  });
560
+ /**
561
+ * The verbosity of the model's response.
562
+ */
563
+ Object.defineProperty(this, "verbosity", {
564
+ enumerable: true,
565
+ configurable: true,
566
+ writable: true,
567
+ value: void 0
568
+ });
558
569
  Object.defineProperty(this, "defaultOptions", {
559
570
  enumerable: true,
560
571
  configurable: true,
@@ -591,11 +602,18 @@ class BaseChatOpenAI extends chat_models_1.BaseChatModel {
591
602
  this.__includeRawResponse = fields?.__includeRawResponse;
592
603
  this.audio = fields?.audio;
593
604
  this.modalities = fields?.modalities;
594
- this.reasoning = fields?.reasoning;
605
+ this.reasoning =
606
+ fields?.reasoning ?? fields?.reasoning_effort
607
+ ? { effort: fields.reasoning_effort }
608
+ : undefined;
595
609
  this.maxTokens = fields?.maxCompletionTokens ?? fields?.maxTokens;
596
610
  this.disableStreaming = fields?.disableStreaming ?? this.disableStreaming;
597
611
  this.promptCacheKey = fields?.promptCacheKey ?? this.promptCacheKey;
612
+ this.verbosity = fields?.verbosity ?? this.verbosity;
598
613
  this.streaming = fields?.streaming ?? false;
614
+ // disable streaming in BaseChatModel if explicitly disabled
615
+ if (this.streaming === false)
616
+ this.disableStreaming = true;
599
617
  if (this.disableStreaming)
600
618
  this.streaming = false;
601
619
  this.streamUsage = fields?.streamUsage ?? this.streamUsage;
@@ -1088,11 +1106,12 @@ class ChatOpenAIResponses extends BaseChatOpenAI {
1088
1106
  name: format.json_schema.name,
1089
1107
  strict: format.json_schema.strict,
1090
1108
  },
1109
+ verbosity: options?.verbosity,
1091
1110
  };
1092
1111
  }
1093
1112
  return undefined;
1094
1113
  }
1095
- return { format };
1114
+ return { format, verbosity: options?.verbosity };
1096
1115
  })(),
1097
1116
  parallel_tool_calls: options?.parallel_tool_calls,
1098
1117
  max_output_tokens: this.maxTokens === -1 ? undefined : this.maxTokens,
@@ -1750,6 +1769,7 @@ class ChatOpenAICompletions extends BaseChatOpenAI {
1750
1769
  : {}),
1751
1770
  ...this.modelKwargs,
1752
1771
  prompt_cache_key: options?.promptCacheKey ?? this.promptCacheKey,
1772
+ verbosity: options?.verbosity ?? this.verbosity,
1753
1773
  };
1754
1774
  if (options?.prediction !== undefined) {
1755
1775
  params.prediction = options.prediction;
@@ -6,7 +6,7 @@ import { BaseChatModel, type LangSmithParams, type BaseChatModelParams } from "@
6
6
  import { type BaseFunctionCallOptions, type BaseLanguageModelInput, type StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
7
7
  import { Runnable } from "@langchain/core/runnables";
8
8
  import { InteropZodType } from "@langchain/core/utils/types";
9
- import { type OpenAICallOptions, type OpenAIChatInput, type OpenAICoreRequestOptions, type ChatOpenAIResponseFormat, ChatOpenAIReasoningSummary, ResponseFormatConfiguration } from "./types.js";
9
+ import { type OpenAICallOptions, type OpenAIChatInput, type OpenAICoreRequestOptions, type ChatOpenAIResponseFormat, ChatOpenAIReasoningSummary, ResponseFormatConfiguration, OpenAIVerbosityParam } from "./types.js";
10
10
  import { OpenAIToolChoice } from "./utils/openai.js";
11
11
  import { ChatOpenAIToolType, ResponsesTool, ResponsesToolChoice } from "./utils/tools.js";
12
12
  interface OpenAILLMOutput {
@@ -115,6 +115,10 @@ export interface BaseChatOpenAICallOptions extends OpenAICallOptions, BaseFuncti
115
115
  * [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
116
116
  */
117
117
  promptCacheKey?: string;
118
+ /**
119
+ * The verbosity of the model's response.
120
+ */
121
+ verbosity?: OpenAIVerbosityParam;
118
122
  }
119
123
  export interface BaseChatOpenAIFields extends Partial<OpenAIChatInput>, BaseChatModelParams {
120
124
  /**
@@ -179,6 +183,10 @@ export declare abstract class BaseChatOpenAI<CallOptions extends BaseChatOpenAIC
179
183
  * [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
180
184
  */
181
185
  promptCacheKey: string;
186
+ /**
187
+ * The verbosity of the model's response.
188
+ */
189
+ verbosity?: OpenAIVerbosityParam;
182
190
  protected defaultOptions: CallOptions;
183
191
  _llmType(): string;
184
192
  static lc_name(): string;
@@ -268,6 +276,10 @@ export interface ChatOpenAIResponsesCallOptions extends BaseChatOpenAICallOption
268
276
  * conversations.
269
277
  */
270
278
  previous_response_id?: OpenAIClient.Responses.ResponseCreateParams["previous_response_id"];
279
+ /**
280
+ * The verbosity of the model's response.
281
+ */
282
+ verbosity?: OpenAIVerbosityParam;
271
283
  }
272
284
  type ChatResponsesInvocationParams = Omit<OpenAIClient.Responses.ResponseCreateParams, "input">;
273
285
  /**
@@ -268,6 +268,7 @@ export class BaseChatOpenAI extends BaseChatModel {
268
268
  "response_format",
269
269
  "seed",
270
270
  "reasoning",
271
+ "reasoning_effort",
271
272
  "service_tier",
272
273
  ];
273
274
  }
@@ -319,8 +320,9 @@ export class BaseChatOpenAI extends BaseChatModel {
319
320
  "disableStreaming",
320
321
  "zdrEnabled",
321
322
  "reasoning",
322
- "verbosity",
323
+ "reasoning_effort",
323
324
  "promptCacheKey",
325
+ "verbosity",
324
326
  ];
325
327
  }
326
328
  getLsParams(options) {
@@ -550,6 +552,15 @@ export class BaseChatOpenAI extends BaseChatModel {
550
552
  writable: true,
551
553
  value: void 0
552
554
  });
555
+ /**
556
+ * The verbosity of the model's response.
557
+ */
558
+ Object.defineProperty(this, "verbosity", {
559
+ enumerable: true,
560
+ configurable: true,
561
+ writable: true,
562
+ value: void 0
563
+ });
553
564
  Object.defineProperty(this, "defaultOptions", {
554
565
  enumerable: true,
555
566
  configurable: true,
@@ -586,11 +597,18 @@ export class BaseChatOpenAI extends BaseChatModel {
586
597
  this.__includeRawResponse = fields?.__includeRawResponse;
587
598
  this.audio = fields?.audio;
588
599
  this.modalities = fields?.modalities;
589
- this.reasoning = fields?.reasoning;
600
+ this.reasoning =
601
+ fields?.reasoning ?? fields?.reasoning_effort
602
+ ? { effort: fields.reasoning_effort }
603
+ : undefined;
590
604
  this.maxTokens = fields?.maxCompletionTokens ?? fields?.maxTokens;
591
605
  this.disableStreaming = fields?.disableStreaming ?? this.disableStreaming;
592
606
  this.promptCacheKey = fields?.promptCacheKey ?? this.promptCacheKey;
607
+ this.verbosity = fields?.verbosity ?? this.verbosity;
593
608
  this.streaming = fields?.streaming ?? false;
609
+ // disable streaming in BaseChatModel if explicitly disabled
610
+ if (this.streaming === false)
611
+ this.disableStreaming = true;
594
612
  if (this.disableStreaming)
595
613
  this.streaming = false;
596
614
  this.streamUsage = fields?.streamUsage ?? this.streamUsage;
@@ -1082,11 +1100,12 @@ export class ChatOpenAIResponses extends BaseChatOpenAI {
1082
1100
  name: format.json_schema.name,
1083
1101
  strict: format.json_schema.strict,
1084
1102
  },
1103
+ verbosity: options?.verbosity,
1085
1104
  };
1086
1105
  }
1087
1106
  return undefined;
1088
1107
  }
1089
- return { format };
1108
+ return { format, verbosity: options?.verbosity };
1090
1109
  })(),
1091
1110
  parallel_tool_calls: options?.parallel_tool_calls,
1092
1111
  max_output_tokens: this.maxTokens === -1 ? undefined : this.maxTokens,
@@ -1743,6 +1762,7 @@ export class ChatOpenAICompletions extends BaseChatOpenAI {
1743
1762
  : {}),
1744
1763
  ...this.modelKwargs,
1745
1764
  prompt_cache_key: options?.promptCacheKey ?? this.promptCacheKey,
1765
+ verbosity: options?.verbosity ?? this.verbosity,
1746
1766
  };
1747
1767
  if (options?.prediction !== undefined) {
1748
1768
  params.prediction = options.prediction;
package/dist/types.d.ts CHANGED
@@ -8,6 +8,7 @@ export type { TiktokenModel };
8
8
  * @see https://platform.openai.com/docs/models
9
9
  */
10
10
  export type OpenAIChatModelId = OpenAIClient.ChatModel | (string & NonNullable<unknown>);
11
+ export type OpenAIVerbosityParam = "low" | "medium" | "high" | null;
11
12
  export declare interface OpenAIBaseInput {
12
13
  /** Sampling temperature to use */
13
14
  temperature: number;
@@ -76,8 +77,10 @@ export declare interface OpenAIBaseInput {
76
77
  * `OPENAI_API_KEY` environment variable.
77
78
  */
78
79
  apiKey?: string;
79
- /** The verbosity of the model's response. */
80
- verbosity: "low" | "medium" | "high";
80
+ /**
81
+ * The verbosity of the model's response.
82
+ */
83
+ verbosity?: OpenAIVerbosityParam;
81
84
  }
82
85
  export type OpenAICoreRequestOptions = OpenAIClient.RequestOptions;
83
86
  export interface OpenAICallOptions extends BaseLanguageModelCallOptions {
@@ -144,6 +147,15 @@ export interface OpenAIChatInput extends OpenAIBaseInput {
144
147
  * API. This option is ignored when not using a reasoning model.
145
148
  */
146
149
  reasoning?: OpenAIClient.Reasoning;
150
+ /**
151
+ * Constrains effort on reasoning for
152
+ * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Reducing reasoning
153
+ * effort can result in faster responses and fewer tokens used on reasoning in a
154
+ * response.
155
+ *
156
+ * @deprecated Use `reasoning` instead.
157
+ */
158
+ reasoning_effort?: OpenAIClient.ReasoningEffort;
147
159
  /**
148
160
  * Should be set to `true` in tenancies with Zero Data Retention
149
161
  * @see https://platform.openai.com/docs/guides/your-data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/openai",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "OpenAI integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -36,7 +36,7 @@
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
38
  "js-tiktoken": "^1.0.12",
39
- "openai": "^5.12.1",
39
+ "openai": "5.12.2",
40
40
  "zod": "^3.25.32"
41
41
  },
42
42
  "peerDependencies": {