@langchain/openai 0.6.7 → 0.6.9
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/dist/chat_models.cjs +20 -3
- package/dist/chat_models.d.ts +13 -1
- package/dist/chat_models.js +20 -3
- package/dist/types.d.ts +5 -2
- package/package.json +2 -2
package/dist/chat_models.cjs
CHANGED
|
@@ -20,7 +20,13 @@ const openai_format_fndef_js_1 = require("./utils/openai-format-fndef.cjs");
|
|
|
20
20
|
const tools_js_1 = require("./utils/tools.cjs");
|
|
21
21
|
const _FUNCTION_CALL_IDS_MAP_KEY = "__openai_function_call_ids__";
|
|
22
22
|
function isReasoningModel(model) {
|
|
23
|
-
|
|
23
|
+
if (!model)
|
|
24
|
+
return false;
|
|
25
|
+
if (/^o\d/.test(model ?? ""))
|
|
26
|
+
return true;
|
|
27
|
+
if (model.startsWith("gpt-5") && !model.startsWith("gpt-5-chat"))
|
|
28
|
+
return true;
|
|
29
|
+
return false;
|
|
24
30
|
}
|
|
25
31
|
function isStructuredOutputMethodParams(x
|
|
26
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -318,8 +324,8 @@ class BaseChatOpenAI extends chat_models_1.BaseChatModel {
|
|
|
318
324
|
"disableStreaming",
|
|
319
325
|
"zdrEnabled",
|
|
320
326
|
"reasoning",
|
|
321
|
-
"verbosity",
|
|
322
327
|
"promptCacheKey",
|
|
328
|
+
"verbosity",
|
|
323
329
|
];
|
|
324
330
|
}
|
|
325
331
|
getLsParams(options) {
|
|
@@ -549,6 +555,15 @@ class BaseChatOpenAI extends chat_models_1.BaseChatModel {
|
|
|
549
555
|
writable: true,
|
|
550
556
|
value: void 0
|
|
551
557
|
});
|
|
558
|
+
/**
|
|
559
|
+
* The verbosity of the model's response.
|
|
560
|
+
*/
|
|
561
|
+
Object.defineProperty(this, "verbosity", {
|
|
562
|
+
enumerable: true,
|
|
563
|
+
configurable: true,
|
|
564
|
+
writable: true,
|
|
565
|
+
value: void 0
|
|
566
|
+
});
|
|
552
567
|
Object.defineProperty(this, "defaultOptions", {
|
|
553
568
|
enumerable: true,
|
|
554
569
|
configurable: true,
|
|
@@ -589,6 +604,7 @@ class BaseChatOpenAI extends chat_models_1.BaseChatModel {
|
|
|
589
604
|
this.maxTokens = fields?.maxCompletionTokens ?? fields?.maxTokens;
|
|
590
605
|
this.disableStreaming = fields?.disableStreaming ?? this.disableStreaming;
|
|
591
606
|
this.promptCacheKey = fields?.promptCacheKey ?? this.promptCacheKey;
|
|
607
|
+
this.verbosity = fields?.verbosity ?? this.verbosity;
|
|
592
608
|
this.streaming = fields?.streaming ?? false;
|
|
593
609
|
if (this.disableStreaming)
|
|
594
610
|
this.streaming = false;
|
|
@@ -1086,7 +1102,7 @@ class ChatOpenAIResponses extends BaseChatOpenAI {
|
|
|
1086
1102
|
}
|
|
1087
1103
|
return undefined;
|
|
1088
1104
|
}
|
|
1089
|
-
return { format };
|
|
1105
|
+
return { format, verbosity: options?.verbosity };
|
|
1090
1106
|
})(),
|
|
1091
1107
|
parallel_tool_calls: options?.parallel_tool_calls,
|
|
1092
1108
|
max_output_tokens: this.maxTokens === -1 ? undefined : this.maxTokens,
|
|
@@ -1744,6 +1760,7 @@ class ChatOpenAICompletions extends BaseChatOpenAI {
|
|
|
1744
1760
|
: {}),
|
|
1745
1761
|
...this.modelKwargs,
|
|
1746
1762
|
prompt_cache_key: options?.promptCacheKey ?? this.promptCacheKey,
|
|
1763
|
+
verbosity: options?.verbosity ?? this.verbosity,
|
|
1747
1764
|
};
|
|
1748
1765
|
if (options?.prediction !== undefined) {
|
|
1749
1766
|
params.prediction = options.prediction;
|
package/dist/chat_models.d.ts
CHANGED
|
@@ -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
|
/**
|
package/dist/chat_models.js
CHANGED
|
@@ -15,7 +15,13 @@ import { formatFunctionDefinitions, } from "./utils/openai-format-fndef.js";
|
|
|
15
15
|
import { _convertToOpenAITool, convertCompletionsCustomTool, convertResponsesCustomTool, isBuiltInTool, isBuiltInToolChoice, isCustomTool, isCustomToolCall, isOpenAICustomTool, parseCustomToolCall, } from "./utils/tools.js";
|
|
16
16
|
const _FUNCTION_CALL_IDS_MAP_KEY = "__openai_function_call_ids__";
|
|
17
17
|
function isReasoningModel(model) {
|
|
18
|
-
|
|
18
|
+
if (!model)
|
|
19
|
+
return false;
|
|
20
|
+
if (/^o\d/.test(model ?? ""))
|
|
21
|
+
return true;
|
|
22
|
+
if (model.startsWith("gpt-5") && !model.startsWith("gpt-5-chat"))
|
|
23
|
+
return true;
|
|
24
|
+
return false;
|
|
19
25
|
}
|
|
20
26
|
function isStructuredOutputMethodParams(x
|
|
21
27
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -313,8 +319,8 @@ export class BaseChatOpenAI extends BaseChatModel {
|
|
|
313
319
|
"disableStreaming",
|
|
314
320
|
"zdrEnabled",
|
|
315
321
|
"reasoning",
|
|
316
|
-
"verbosity",
|
|
317
322
|
"promptCacheKey",
|
|
323
|
+
"verbosity",
|
|
318
324
|
];
|
|
319
325
|
}
|
|
320
326
|
getLsParams(options) {
|
|
@@ -544,6 +550,15 @@ export class BaseChatOpenAI extends BaseChatModel {
|
|
|
544
550
|
writable: true,
|
|
545
551
|
value: void 0
|
|
546
552
|
});
|
|
553
|
+
/**
|
|
554
|
+
* The verbosity of the model's response.
|
|
555
|
+
*/
|
|
556
|
+
Object.defineProperty(this, "verbosity", {
|
|
557
|
+
enumerable: true,
|
|
558
|
+
configurable: true,
|
|
559
|
+
writable: true,
|
|
560
|
+
value: void 0
|
|
561
|
+
});
|
|
547
562
|
Object.defineProperty(this, "defaultOptions", {
|
|
548
563
|
enumerable: true,
|
|
549
564
|
configurable: true,
|
|
@@ -584,6 +599,7 @@ export class BaseChatOpenAI extends BaseChatModel {
|
|
|
584
599
|
this.maxTokens = fields?.maxCompletionTokens ?? fields?.maxTokens;
|
|
585
600
|
this.disableStreaming = fields?.disableStreaming ?? this.disableStreaming;
|
|
586
601
|
this.promptCacheKey = fields?.promptCacheKey ?? this.promptCacheKey;
|
|
602
|
+
this.verbosity = fields?.verbosity ?? this.verbosity;
|
|
587
603
|
this.streaming = fields?.streaming ?? false;
|
|
588
604
|
if (this.disableStreaming)
|
|
589
605
|
this.streaming = false;
|
|
@@ -1080,7 +1096,7 @@ export class ChatOpenAIResponses extends BaseChatOpenAI {
|
|
|
1080
1096
|
}
|
|
1081
1097
|
return undefined;
|
|
1082
1098
|
}
|
|
1083
|
-
return { format };
|
|
1099
|
+
return { format, verbosity: options?.verbosity };
|
|
1084
1100
|
})(),
|
|
1085
1101
|
parallel_tool_calls: options?.parallel_tool_calls,
|
|
1086
1102
|
max_output_tokens: this.maxTokens === -1 ? undefined : this.maxTokens,
|
|
@@ -1737,6 +1753,7 @@ export class ChatOpenAICompletions extends BaseChatOpenAI {
|
|
|
1737
1753
|
: {}),
|
|
1738
1754
|
...this.modelKwargs,
|
|
1739
1755
|
prompt_cache_key: options?.promptCacheKey ?? this.promptCacheKey,
|
|
1756
|
+
verbosity: options?.verbosity ?? this.verbosity,
|
|
1740
1757
|
};
|
|
1741
1758
|
if (options?.prediction !== undefined) {
|
|
1742
1759
|
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
|
-
/**
|
|
80
|
-
|
|
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 {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/openai",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
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": "
|
|
39
|
+
"openai": "5.12.2",
|
|
40
40
|
"zod": "^3.25.32"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|