@langchain/openai 0.6.8 → 1.0.0-alpha.1
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/README.md +8 -8
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/azure/chat_models.cjs +661 -808
- package/dist/azure/chat_models.cjs.map +1 -0
- package/dist/azure/chat_models.d.cts +449 -0
- package/dist/azure/chat_models.d.cts.map +1 -0
- package/dist/azure/chat_models.d.ts +32 -28
- package/dist/azure/chat_models.d.ts.map +1 -0
- package/dist/azure/chat_models.js +660 -804
- package/dist/azure/chat_models.js.map +1 -0
- package/dist/azure/embeddings.cjs +81 -130
- package/dist/azure/embeddings.cjs.map +1 -0
- package/dist/azure/embeddings.d.cts +27 -0
- package/dist/azure/embeddings.d.cts.map +1 -0
- package/dist/azure/embeddings.d.ts +25 -20
- package/dist/azure/embeddings.d.ts.map +1 -0
- package/dist/azure/embeddings.js +80 -126
- package/dist/azure/embeddings.js.map +1 -0
- package/dist/azure/llms.cjs +109 -168
- package/dist/azure/llms.cjs.map +1 -0
- package/dist/azure/llms.d.cts +33 -0
- package/dist/azure/llms.d.cts.map +1 -0
- package/dist/azure/llms.d.ts +31 -25
- package/dist/azure/llms.d.ts.map +1 -0
- package/dist/azure/llms.js +108 -164
- package/dist/azure/llms.js.map +1 -0
- package/dist/chat_models.cjs +1951 -2763
- package/dist/chat_models.cjs.map +1 -0
- package/dist/chat_models.d.cts +930 -0
- package/dist/chat_models.d.cts.map +1 -0
- package/dist/chat_models.d.ts +365 -336
- package/dist/chat_models.d.ts.map +1 -0
- package/dist/chat_models.js +1946 -2753
- package/dist/chat_models.js.map +1 -0
- package/dist/embeddings.cjs +136 -193
- package/dist/embeddings.cjs.map +1 -0
- package/dist/embeddings.d.cts +115 -0
- package/dist/embeddings.d.cts.map +1 -0
- package/dist/embeddings.d.ts +88 -81
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +134 -188
- package/dist/embeddings.js.map +1 -0
- package/dist/index.cjs +47 -34
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -13
- package/dist/index.js +17 -13
- package/dist/langchain-core/dist/types/_internal.d.cts +11 -0
- package/dist/langchain-core/dist/types/_internal.d.cts.map +1 -0
- package/dist/langchain-core/dist/types/_internal.d.ts +11 -0
- package/dist/langchain-core/dist/types/_internal.d.ts.map +1 -0
- package/dist/langchain-core/dist/utils/stream.d.cts +26 -0
- package/dist/langchain-core/dist/utils/stream.d.cts.map +1 -0
- package/dist/langchain-core/dist/utils/stream.d.ts +26 -0
- package/dist/langchain-core/dist/utils/stream.d.ts.map +1 -0
- package/dist/llms.cjs +312 -468
- package/dist/llms.cjs.map +1 -0
- package/dist/llms.d.cts +123 -0
- package/dist/llms.d.cts.map +1 -0
- package/dist/llms.d.ts +93 -87
- package/dist/llms.d.ts.map +1 -0
- package/dist/llms.js +309 -462
- package/dist/llms.js.map +1 -0
- package/dist/tools/custom.cjs +25 -26
- package/dist/tools/custom.cjs.map +1 -0
- package/dist/tools/custom.d.cts +10 -0
- package/dist/tools/custom.d.cts.map +1 -0
- package/dist/tools/custom.d.ts +8 -3
- package/dist/tools/custom.d.ts.map +1 -0
- package/dist/tools/custom.js +24 -23
- package/dist/tools/custom.js.map +1 -0
- package/dist/tools/dalle.cjs +104 -194
- package/dist/tools/dalle.cjs.map +1 -0
- package/dist/tools/dalle.d.cts +123 -0
- package/dist/tools/dalle.d.cts.map +1 -0
- package/dist/tools/dalle.d.ts +111 -104
- package/dist/tools/dalle.d.ts.map +1 -0
- package/dist/tools/dalle.js +102 -189
- package/dist/tools/dalle.js.map +1 -0
- package/dist/tools/index.cjs +1 -17
- package/dist/tools/index.js +1 -1
- package/dist/types.d.cts +263 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +244 -234
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/azure.cjs +86 -47
- package/dist/utils/azure.cjs.map +1 -0
- package/dist/utils/azure.d.cts +76 -0
- package/dist/utils/azure.d.cts.map +1 -0
- package/dist/utils/azure.d.ts +51 -9
- package/dist/utils/azure.d.ts.map +1 -0
- package/dist/utils/azure.js +85 -45
- package/dist/utils/azure.js.map +1 -0
- package/dist/utils/client.cjs +25 -0
- package/dist/utils/client.cjs.map +1 -0
- package/dist/utils/client.d.cts +5 -0
- package/dist/utils/client.d.cts.map +1 -0
- package/dist/utils/client.d.ts +5 -0
- package/dist/utils/client.d.ts.map +1 -0
- package/dist/utils/client.js +24 -0
- package/dist/utils/client.js.map +1 -0
- package/dist/utils/errors.cjs +9 -8
- package/dist/utils/errors.cjs.map +1 -0
- package/dist/utils/errors.js +9 -6
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/message_inputs.cjs +139 -0
- package/dist/utils/message_inputs.cjs.map +1 -0
- package/dist/utils/message_inputs.d.cts +9 -0
- package/dist/utils/message_inputs.d.cts.map +1 -0
- package/dist/utils/message_inputs.d.ts +9 -0
- package/dist/utils/message_inputs.d.ts.map +1 -0
- package/dist/utils/message_inputs.js +137 -0
- package/dist/utils/message_inputs.js.map +1 -0
- package/dist/utils/misc.cjs +30 -0
- package/dist/utils/misc.cjs.map +1 -0
- package/dist/utils/misc.d.cts +9 -0
- package/dist/utils/misc.d.cts.map +1 -0
- package/dist/utils/misc.d.ts +9 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +27 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/output.cjs +74 -0
- package/dist/utils/output.cjs.map +1 -0
- package/dist/utils/output.js +72 -0
- package/dist/utils/output.js.map +1 -0
- package/dist/utils/prompts.cjs +39 -38
- package/dist/utils/prompts.cjs.map +1 -0
- package/dist/utils/prompts.d.cts +42 -0
- package/dist/utils/prompts.d.cts.map +1 -0
- package/dist/utils/prompts.d.ts +10 -4
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +40 -36
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/standard.cjs +113 -0
- package/dist/utils/standard.cjs.map +1 -0
- package/dist/utils/standard.js +111 -0
- package/dist/utils/standard.js.map +1 -0
- package/dist/utils/tools.cjs +150 -127
- package/dist/utils/tools.cjs.map +1 -0
- package/dist/utils/tools.d.cts +13 -0
- package/dist/utils/tools.d.cts.map +1 -0
- package/dist/utils/tools.d.ts +12 -42
- package/dist/utils/tools.d.ts.map +1 -0
- package/dist/utils/tools.js +146 -123
- package/dist/utils/tools.js.map +1 -0
- package/package.json +33 -41
- package/dist/tools/index.d.ts +0 -1
- package/dist/types.cjs +0 -2
- package/dist/types.js +0 -1
- package/dist/utils/errors.d.ts +0 -2
- package/dist/utils/headers.cjs +0 -39
- package/dist/utils/headers.d.ts +0 -8
- package/dist/utils/headers.js +0 -35
- package/dist/utils/openai-format-fndef.cjs +0 -80
- package/dist/utils/openai-format-fndef.d.ts +0 -44
- package/dist/utils/openai-format-fndef.js +0 -77
- package/dist/utils/openai.cjs +0 -127
- package/dist/utils/openai.d.ts +0 -15
- package/dist/utils/openai.js +0 -119
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
package/dist/chat_models.d.ts
CHANGED
|
@@ -1,275 +1,300 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { IterableReadableStream } from "./langchain-core/dist/utils/stream.js";
|
|
2
|
+
import { ChatOpenAIReasoningSummary, ChatOpenAIResponseFormat, OpenAICallOptions, OpenAIChatInput, OpenAICoreRequestOptions, OpenAIVerbosityParam, ResponseFormatConfiguration } from "./types.js";
|
|
3
|
+
import { ChatOpenAIToolType, OpenAIToolChoice, ResponsesTool, ResponsesToolChoice } from "./utils/tools.js";
|
|
4
|
+
import { ClientOptions, OpenAI as OpenAI$1 } from "openai";
|
|
5
|
+
import { AIMessageChunk, BaseMessage, ChatMessageChunk, FunctionMessageChunk, HumanMessageChunk, SystemMessageChunk, ToolMessageChunk } from "@langchain/core/messages";
|
|
6
|
+
import { ChatGeneration, ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
|
|
7
|
+
import { BaseChatModel, BaseChatModelParams, LangSmithParams } from "@langchain/core/language_models/chat_models";
|
|
8
|
+
import { BaseFunctionCallOptions, BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
|
|
7
9
|
import { Runnable } from "@langchain/core/runnables";
|
|
8
10
|
import { InteropZodType } from "@langchain/core/utils/types";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
|
|
12
|
+
|
|
13
|
+
//#region src/chat_models.d.ts
|
|
12
14
|
interface OpenAILLMOutput {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
tokenUsage: {
|
|
16
|
+
completionTokens?: number;
|
|
17
|
+
promptTokens?: number;
|
|
18
|
+
totalTokens?: number;
|
|
19
|
+
};
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
21
|
+
interface BaseChatOpenAICallOptions extends OpenAICallOptions, BaseFunctionCallOptions {
|
|
22
|
+
/**
|
|
23
|
+
* A list of tools that the model may use to generate responses.
|
|
24
|
+
* Each tool can be a function, a built-in tool, or a custom tool definition.
|
|
25
|
+
* If not provided, the model will not use any tools.
|
|
26
|
+
*/
|
|
27
|
+
tools?: ChatOpenAIToolType[];
|
|
28
|
+
/**
|
|
29
|
+
* Specifies which tool the model should use to respond.
|
|
30
|
+
* Can be an {@link OpenAIToolChoice} or a {@link ResponsesToolChoice}.
|
|
31
|
+
* If not set, the model will decide which tool to use automatically.
|
|
32
|
+
*/
|
|
33
|
+
// TODO: break OpenAIToolChoice and ResponsesToolChoice into options sub classes
|
|
34
|
+
tool_choice?: OpenAIToolChoice | ResponsesToolChoice;
|
|
35
|
+
/**
|
|
36
|
+
* Adds a prompt index to prompts passed to the model to track
|
|
37
|
+
* what prompt is being used for a given generation.
|
|
38
|
+
*/
|
|
39
|
+
promptIndex?: number;
|
|
40
|
+
/**
|
|
41
|
+
* An object specifying the format that the model must output.
|
|
42
|
+
*/
|
|
43
|
+
response_format?: ChatOpenAIResponseFormat;
|
|
44
|
+
/**
|
|
45
|
+
* When provided, the completions API will make a best effort to sample
|
|
46
|
+
* deterministically, such that repeated requests with the same `seed`
|
|
47
|
+
* and parameters should return the same result.
|
|
48
|
+
*/
|
|
49
|
+
seed?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Additional options to pass to streamed completions.
|
|
52
|
+
* If provided, this takes precedence over "streamUsage" set at
|
|
53
|
+
* initialization time.
|
|
54
|
+
*/
|
|
55
|
+
stream_options?: OpenAI$1.Chat.ChatCompletionStreamOptions;
|
|
56
|
+
/**
|
|
57
|
+
* The model may choose to call multiple functions in a single turn. You can
|
|
58
|
+
* set parallel_tool_calls to false which ensures only one tool is called at most.
|
|
59
|
+
* [Learn more](https://platform.openai.com/docs/guides/function-calling#parallel-function-calling)
|
|
60
|
+
*/
|
|
61
|
+
parallel_tool_calls?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* If `true`, model output is guaranteed to exactly match the JSON Schema
|
|
64
|
+
* provided in the tool definition. If `true`, the input schema will also be
|
|
65
|
+
* validated according to
|
|
66
|
+
* https://platform.openai.com/docs/guides/structured-outputs/supported-schemas.
|
|
67
|
+
*
|
|
68
|
+
* If `false`, input schema will not be validated and model output will not
|
|
69
|
+
* be validated.
|
|
70
|
+
*
|
|
71
|
+
* If `undefined`, `strict` argument will not be passed to the model.
|
|
72
|
+
*/
|
|
73
|
+
strict?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Output types that you would like the model to generate for this request. Most
|
|
76
|
+
* models are capable of generating text, which is the default:
|
|
77
|
+
*
|
|
78
|
+
* `["text"]`
|
|
79
|
+
*
|
|
80
|
+
* The `gpt-4o-audio-preview` model can also be used to
|
|
81
|
+
* [generate audio](https://platform.openai.com/docs/guides/audio). To request that
|
|
82
|
+
* this model generate both text and audio responses, you can use:
|
|
83
|
+
*
|
|
84
|
+
* `["text", "audio"]`
|
|
85
|
+
*/
|
|
86
|
+
modalities?: Array<OpenAI$1.Chat.ChatCompletionModality>;
|
|
87
|
+
/**
|
|
88
|
+
* Parameters for audio output. Required when audio output is requested with
|
|
89
|
+
* `modalities: ["audio"]`.
|
|
90
|
+
* [Learn more](https://platform.openai.com/docs/guides/audio).
|
|
91
|
+
*/
|
|
92
|
+
audio?: OpenAI$1.Chat.ChatCompletionAudioParam;
|
|
93
|
+
/**
|
|
94
|
+
* Static predicted output content, such as the content of a text file that is being regenerated.
|
|
95
|
+
* [Learn more](https://platform.openai.com/docs/guides/latency-optimization#use-predicted-outputs).
|
|
96
|
+
*/
|
|
97
|
+
prediction?: OpenAI$1.ChatCompletionPredictionContent;
|
|
98
|
+
/**
|
|
99
|
+
* Options for reasoning models.
|
|
100
|
+
*
|
|
101
|
+
* Note that some options, like reasoning summaries, are only available when using the responses
|
|
102
|
+
* API. If these options are set, the responses API will be used to fulfill the request.
|
|
103
|
+
*
|
|
104
|
+
* These options will be ignored when not using a reasoning model.
|
|
105
|
+
*/
|
|
106
|
+
reasoning?: OpenAI$1.Reasoning;
|
|
107
|
+
/**
|
|
108
|
+
* Service tier to use for this request. Can be "auto", "default", or "flex"
|
|
109
|
+
* Specifies the service tier for prioritization and latency optimization.
|
|
110
|
+
*/
|
|
111
|
+
service_tier?: OpenAI$1.Chat.ChatCompletionCreateParams["service_tier"];
|
|
112
|
+
/**
|
|
113
|
+
* Used by OpenAI to cache responses for similar requests to optimize your cache
|
|
114
|
+
* hit rates. Replaces the `user` field.
|
|
115
|
+
* [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
|
|
116
|
+
*/
|
|
117
|
+
promptCacheKey?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The verbosity of the model's response.
|
|
120
|
+
*/
|
|
121
|
+
verbosity?: OpenAIVerbosityParam;
|
|
118
122
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
interface BaseChatOpenAIFields extends Partial<OpenAIChatInput>, BaseChatModelParams {
|
|
124
|
+
/**
|
|
125
|
+
* Optional configuration options for the OpenAI client.
|
|
126
|
+
*/
|
|
127
|
+
configuration?: ClientOptions;
|
|
124
128
|
}
|
|
125
129
|
/** @internal */
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
130
|
+
declare abstract class BaseChatOpenAI<CallOptions extends BaseChatOpenAICallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements Partial<OpenAIChatInput> {
|
|
131
|
+
temperature?: number;
|
|
132
|
+
topP?: number;
|
|
133
|
+
frequencyPenalty?: number;
|
|
134
|
+
presencePenalty?: number;
|
|
135
|
+
n?: number;
|
|
136
|
+
logitBias?: Record<string, number>;
|
|
137
|
+
model: string;
|
|
138
|
+
modelKwargs?: OpenAIChatInput["modelKwargs"];
|
|
139
|
+
stop?: string[];
|
|
140
|
+
stopSequences?: string[];
|
|
141
|
+
user?: string;
|
|
142
|
+
timeout?: number;
|
|
143
|
+
streaming: boolean;
|
|
144
|
+
streamUsage: boolean;
|
|
145
|
+
maxTokens?: number;
|
|
146
|
+
logprobs?: boolean;
|
|
147
|
+
topLogprobs?: number;
|
|
148
|
+
apiKey?: string;
|
|
149
|
+
organization?: string;
|
|
150
|
+
__includeRawResponse?: boolean;
|
|
151
|
+
/** @internal */
|
|
152
|
+
client: OpenAI$1;
|
|
153
|
+
/** @internal */
|
|
154
|
+
clientConfig: ClientOptions;
|
|
155
|
+
/**
|
|
156
|
+
* Whether the model supports the `strict` argument when passing in tools.
|
|
157
|
+
* If `undefined` the `strict` argument will not be passed to OpenAI.
|
|
158
|
+
*/
|
|
159
|
+
supportsStrictToolCalling?: boolean;
|
|
160
|
+
audio?: OpenAI$1.Chat.ChatCompletionAudioParam;
|
|
161
|
+
modalities?: Array<OpenAI$1.Chat.ChatCompletionModality>;
|
|
162
|
+
reasoning?: OpenAI$1.Reasoning;
|
|
163
|
+
/**
|
|
164
|
+
* Must be set to `true` in tenancies with Zero Data Retention. Setting to `true` will disable
|
|
165
|
+
* output storage in the Responses API, but this DOES NOT enable Zero Data Retention in your
|
|
166
|
+
* OpenAI organization or project. This must be configured directly with OpenAI.
|
|
167
|
+
*
|
|
168
|
+
* See:
|
|
169
|
+
* https://help.openai.com/en/articles/10503543-data-residency-for-the-openai-api
|
|
170
|
+
* https://platform.openai.com/docs/api-reference/responses/create#responses-create-store
|
|
171
|
+
*
|
|
172
|
+
* @default false
|
|
173
|
+
*/
|
|
174
|
+
zdrEnabled?: boolean | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Service tier to use for this request. Can be "auto", "default", or "flex" or "priority".
|
|
177
|
+
* Specifies the service tier for prioritization and latency optimization.
|
|
178
|
+
*/
|
|
179
|
+
service_tier?: OpenAI$1.Chat.ChatCompletionCreateParams["service_tier"];
|
|
180
|
+
/**
|
|
181
|
+
* Used by OpenAI to cache responses for similar requests to optimize your cache
|
|
182
|
+
* hit rates.
|
|
183
|
+
* [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
|
|
184
|
+
*/
|
|
185
|
+
promptCacheKey: string;
|
|
186
|
+
/**
|
|
187
|
+
* The verbosity of the model's response.
|
|
188
|
+
*/
|
|
189
|
+
verbosity?: OpenAIVerbosityParam;
|
|
190
|
+
protected defaultOptions: CallOptions;
|
|
191
|
+
_llmType(): string;
|
|
192
|
+
static lc_name(): string;
|
|
193
|
+
get callKeys(): string[];
|
|
194
|
+
lc_serializable: boolean;
|
|
195
|
+
get lc_secrets(): {
|
|
196
|
+
[key: string]: string;
|
|
197
|
+
} | undefined;
|
|
198
|
+
get lc_aliases(): Record<string, string>;
|
|
199
|
+
get lc_serializable_keys(): string[];
|
|
200
|
+
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
201
|
+
/** @ignore */
|
|
202
|
+
_identifyingParams(): Omit<OpenAI$1.Chat.ChatCompletionCreateParams, "messages"> & {
|
|
203
|
+
model_name: string;
|
|
204
|
+
} & ClientOptions;
|
|
205
|
+
/**
|
|
206
|
+
* Get the identifying parameters for the model
|
|
207
|
+
*/
|
|
208
|
+
identifyingParams(): Omit<OpenAI$1.ChatCompletionCreateParams, "messages"> & {
|
|
209
|
+
model_name: string;
|
|
210
|
+
} & ClientOptions;
|
|
211
|
+
constructor(fields?: BaseChatOpenAIFields);
|
|
212
|
+
/**
|
|
213
|
+
* Returns backwards compatible reasoning parameters from constructor params and call options
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
216
|
+
protected _getReasoningParams(options?: this["ParsedCallOptions"]): OpenAI$1.Reasoning | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* Returns an openai compatible response format from a set of options
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
protected _getResponseFormat(resFormat?: CallOptions["response_format"]): ResponseFormatConfiguration | undefined;
|
|
222
|
+
protected _combineCallOptions(additionalOptions?: this["ParsedCallOptions"]): this["ParsedCallOptions"];
|
|
223
|
+
/** @internal */
|
|
224
|
+
_getClientOptions(options: OpenAICoreRequestOptions | undefined): OpenAICoreRequestOptions;
|
|
225
|
+
// TODO: move to completions class
|
|
226
|
+
protected _convertChatOpenAIToolToCompletionsTool(tool: ChatOpenAIToolType, fields?: {
|
|
227
|
+
strict?: boolean;
|
|
228
|
+
}): OpenAI$1.ChatCompletionTool;
|
|
229
|
+
bindTools(tools: ChatOpenAIToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;
|
|
230
|
+
stream(input: BaseLanguageModelInput, options?: CallOptions): Promise<IterableReadableStream<AIMessageChunk>>;
|
|
231
|
+
invoke(input: BaseLanguageModelInput, options?: CallOptions): Promise<AIMessageChunk>;
|
|
232
|
+
/** @ignore */
|
|
233
|
+
_combineLLMOutput(...llmOutputs: OpenAILLMOutput[]): OpenAILLMOutput;
|
|
234
|
+
getNumTokensFromMessages(messages: BaseMessage[]): Promise<{
|
|
235
|
+
totalCount: number;
|
|
236
|
+
countPerMessage: number[];
|
|
237
|
+
}>;
|
|
238
|
+
/** @internal */
|
|
239
|
+
protected _getNumTokensFromGenerations(generations: ChatGeneration[]): Promise<number>;
|
|
240
|
+
/** @internal */
|
|
241
|
+
protected _getEstimatedTokenCountFromPrompt(messages: BaseMessage[], functions?: OpenAI$1.Chat.ChatCompletionCreateParams.Function[], function_call?: "none" | "auto" | OpenAI$1.Chat.ChatCompletionFunctionCallOption): Promise<number>;
|
|
242
|
+
/** @internal */
|
|
243
|
+
protected _getStructuredOutputMethod(config: StructuredOutputMethodOptions<boolean>): string | undefined;
|
|
244
|
+
withStructuredOutput<
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
246
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
248
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
249
|
+
withStructuredOutput<
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
251
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
254
|
+
raw: BaseMessage;
|
|
255
|
+
parsed: RunOutput;
|
|
256
|
+
}>;
|
|
257
|
+
withStructuredOutput<
|
|
258
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
259
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
261
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
|
|
262
|
+
raw: BaseMessage;
|
|
263
|
+
parsed: RunOutput;
|
|
264
|
+
}>;
|
|
244
265
|
}
|
|
266
|
+
interface ChatOpenAIResponsesCallOptions extends BaseChatOpenAICallOptions {
|
|
267
|
+
/**
|
|
268
|
+
* Configuration options for a text response from the model. Can be plain text or
|
|
269
|
+
* structured JSON data.
|
|
270
|
+
*/
|
|
271
|
+
text?: OpenAI$1.Responses.ResponseCreateParams["text"];
|
|
272
|
+
/**
|
|
273
|
+
* The truncation strategy to use for the model response.
|
|
274
|
+
*/
|
|
275
|
+
truncation?: OpenAI$1.Responses.ResponseCreateParams["truncation"];
|
|
276
|
+
/**
|
|
277
|
+
* Specify additional output data to include in the model response.
|
|
278
|
+
*/
|
|
279
|
+
include?: OpenAI$1.Responses.ResponseCreateParams["include"];
|
|
280
|
+
/**
|
|
281
|
+
* The unique ID of the previous response to the model. Use this to create multi-turn
|
|
282
|
+
* conversations.
|
|
283
|
+
*/
|
|
284
|
+
previous_response_id?: OpenAI$1.Responses.ResponseCreateParams["previous_response_id"];
|
|
285
|
+
/**
|
|
286
|
+
* The verbosity of the model's response.
|
|
287
|
+
*/
|
|
288
|
+
verbosity?: OpenAIVerbosityParam;
|
|
289
|
+
}
|
|
290
|
+
type ChatResponsesInvocationParams = Omit<OpenAI$1.Responses.ResponseCreateParams, "input">;
|
|
245
291
|
type ExcludeController<T> = T extends {
|
|
246
|
-
|
|
292
|
+
controller: unknown;
|
|
247
293
|
} ? never : T;
|
|
248
|
-
type ResponsesCreate =
|
|
249
|
-
type ResponsesParse =
|
|
294
|
+
type ResponsesCreate = OpenAI$1.Responses["create"];
|
|
295
|
+
type ResponsesParse = OpenAI$1.Responses["parse"];
|
|
250
296
|
type ResponsesCreateInvoke = ExcludeController<Awaited<ReturnType<ResponsesCreate>>>;
|
|
251
297
|
type ResponsesParseInvoke = ExcludeController<Awaited<ReturnType<ResponsesParse>>>;
|
|
252
|
-
export interface ChatOpenAIResponsesCallOptions extends BaseChatOpenAICallOptions {
|
|
253
|
-
/**
|
|
254
|
-
* Configuration options for a text response from the model. Can be plain text or
|
|
255
|
-
* structured JSON data.
|
|
256
|
-
*/
|
|
257
|
-
text?: OpenAIClient.Responses.ResponseCreateParams["text"];
|
|
258
|
-
/**
|
|
259
|
-
* The truncation strategy to use for the model response.
|
|
260
|
-
*/
|
|
261
|
-
truncation?: OpenAIClient.Responses.ResponseCreateParams["truncation"];
|
|
262
|
-
/**
|
|
263
|
-
* Specify additional output data to include in the model response.
|
|
264
|
-
*/
|
|
265
|
-
include?: OpenAIClient.Responses.ResponseCreateParams["include"];
|
|
266
|
-
/**
|
|
267
|
-
* The unique ID of the previous response to the model. Use this to create multi-turn
|
|
268
|
-
* conversations.
|
|
269
|
-
*/
|
|
270
|
-
previous_response_id?: OpenAIClient.Responses.ResponseCreateParams["previous_response_id"];
|
|
271
|
-
}
|
|
272
|
-
type ChatResponsesInvocationParams = Omit<OpenAIClient.Responses.ResponseCreateParams, "input">;
|
|
273
298
|
/**
|
|
274
299
|
* OpenAI Responses API implementation.
|
|
275
300
|
*
|
|
@@ -277,70 +302,71 @@ type ChatResponsesInvocationParams = Omit<OpenAIClient.Responses.ResponseCreateP
|
|
|
277
302
|
*
|
|
278
303
|
* @internal
|
|
279
304
|
*/
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
export interface ChatOpenAICompletionsCallOptions extends BaseChatOpenAICallOptions {
|
|
305
|
+
declare class ChatOpenAIResponses<CallOptions extends ChatOpenAIResponsesCallOptions = ChatOpenAIResponsesCallOptions> extends BaseChatOpenAI<CallOptions> {
|
|
306
|
+
invocationParams(options?: this["ParsedCallOptions"]): ChatResponsesInvocationParams;
|
|
307
|
+
_generate(messages: BaseMessage[], options: this["ParsedCallOptions"]): Promise<ChatResult>;
|
|
308
|
+
_streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
309
|
+
/**
|
|
310
|
+
* Calls the Responses API with retry logic in case of failures.
|
|
311
|
+
* @param request The request to send to the OpenAI API.
|
|
312
|
+
* @param options Optional configuration for the API call.
|
|
313
|
+
* @returns The response from the OpenAI API.
|
|
314
|
+
*/
|
|
315
|
+
completionWithRetry(request: OpenAI$1.Responses.ResponseCreateParamsStreaming, requestOptions?: OpenAI$1.RequestOptions): Promise<AsyncIterable<OpenAI$1.Responses.ResponseStreamEvent>>;
|
|
316
|
+
completionWithRetry(request: OpenAI$1.Responses.ResponseCreateParamsNonStreaming, requestOptions?: OpenAI$1.RequestOptions): Promise<OpenAI$1.Responses.Response>;
|
|
317
|
+
/** @internal */
|
|
318
|
+
protected _convertResponsesMessageToBaseMessage(response: ResponsesCreateInvoke | ResponsesParseInvoke): BaseMessage;
|
|
319
|
+
/** @internal */
|
|
320
|
+
protected _convertResponsesDeltaToBaseMessageChunk(chunk: OpenAI$1.Responses.ResponseStreamEvent): ChatGenerationChunk | null;
|
|
321
|
+
/** @internal */
|
|
322
|
+
protected _convertMessagesToResponsesParams(messages: BaseMessage[]): (OpenAI$1.Responses.ResponseInputItem.ComputerCallOutput | OpenAI$1.Responses.EasyInputMessage | OpenAI$1.Responses.ResponseInputItem.FunctionCallOutput | OpenAI$1.Responses.ResponseInputItem.ImageGenerationCall | OpenAI$1.Responses.ResponseInputItem.ItemReference | OpenAI$1.Responses.ResponseInputItem.LocalShellCall | OpenAI$1.Responses.ResponseInputItem.LocalShellCallOutput | OpenAI$1.Responses.ResponseInputItem.McpApprovalRequest | OpenAI$1.Responses.ResponseInputItem.McpApprovalResponse | OpenAI$1.Responses.ResponseInputItem.McpCall | OpenAI$1.Responses.ResponseInputItem.McpListTools | OpenAI$1.Responses.ResponseInputItem.Message | OpenAI$1.Responses.ResponseCodeInterpreterToolCall | OpenAI$1.Responses.ResponseComputerToolCall | OpenAI$1.Responses.ResponseCustomToolCall | OpenAI$1.Responses.ResponseCustomToolCallOutput | OpenAI$1.Responses.ResponseFileSearchToolCall | OpenAI$1.Responses.ResponseFunctionToolCall | OpenAI$1.Responses.ResponseFunctionWebSearch | OpenAI$1.Responses.ResponseOutputMessage | OpenAI$1.Responses.ResponseReasoningItem)[];
|
|
323
|
+
/** @internal */
|
|
324
|
+
protected _convertReasoningSummary(reasoning: ChatOpenAIReasoningSummary): OpenAI$1.Responses.ResponseReasoningItem;
|
|
325
|
+
/** @internal */
|
|
326
|
+
protected _reduceChatOpenAITools(tools: ChatOpenAIToolType[], fields: {
|
|
327
|
+
stream?: boolean;
|
|
328
|
+
strict?: boolean;
|
|
329
|
+
}): ResponsesTool[];
|
|
307
330
|
}
|
|
308
|
-
|
|
331
|
+
interface ChatOpenAICompletionsCallOptions extends BaseChatOpenAICallOptions {}
|
|
332
|
+
type ChatCompletionsInvocationParams = Omit<OpenAI$1.Chat.Completions.ChatCompletionCreateParams, "messages">;
|
|
309
333
|
/**
|
|
310
334
|
* OpenAI Completions API implementation.
|
|
311
335
|
* @internal
|
|
312
336
|
*/
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
337
|
+
declare class ChatOpenAICompletions<CallOptions extends ChatOpenAICompletionsCallOptions = ChatOpenAICompletionsCallOptions> extends BaseChatOpenAI<CallOptions> {
|
|
338
|
+
/** @internal */
|
|
339
|
+
invocationParams(options?: this["ParsedCallOptions"], extra?: {
|
|
340
|
+
streaming?: boolean;
|
|
341
|
+
}): ChatCompletionsInvocationParams;
|
|
342
|
+
_generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
343
|
+
_streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
344
|
+
completionWithRetry(request: OpenAI$1.Chat.ChatCompletionCreateParamsStreaming, requestOptions?: OpenAI$1.RequestOptions): Promise<AsyncIterable<OpenAI$1.Chat.Completions.ChatCompletionChunk>>;
|
|
345
|
+
completionWithRetry(request: OpenAI$1.Chat.ChatCompletionCreateParamsNonStreaming, requestOptions?: OpenAI$1.RequestOptions): Promise<OpenAI$1.Chat.Completions.ChatCompletion>;
|
|
346
|
+
/** @internal */
|
|
347
|
+
protected _convertCompletionsMessageToBaseMessage(message: OpenAI$1.Chat.Completions.ChatCompletionMessage, rawResponse: OpenAI$1.Chat.Completions.ChatCompletion): BaseMessage;
|
|
348
|
+
/** @internal */
|
|
349
|
+
protected _convertCompletionsDeltaToBaseMessageChunk(
|
|
350
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351
|
+
delta: Record<string, any>, rawResponse: OpenAI$1.Chat.Completions.ChatCompletionChunk, defaultRole?: OpenAI$1.Chat.ChatCompletionRole): AIMessageChunk | ChatMessageChunk | FunctionMessageChunk | HumanMessageChunk | SystemMessageChunk | ToolMessageChunk;
|
|
326
352
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
353
|
+
type ChatOpenAICallOptions = ChatOpenAICompletionsCallOptions & ChatOpenAIResponsesCallOptions;
|
|
354
|
+
interface ChatOpenAIFields extends BaseChatOpenAIFields {
|
|
355
|
+
/**
|
|
356
|
+
* Whether to use the responses API for all requests. If `false` the responses API will be used
|
|
357
|
+
* only when required in order to fulfill the request.
|
|
358
|
+
*/
|
|
359
|
+
useResponsesApi?: boolean;
|
|
360
|
+
/**
|
|
361
|
+
* The completions chat instance
|
|
362
|
+
* @internal
|
|
363
|
+
*/
|
|
364
|
+
completions?: ChatOpenAICompletions;
|
|
365
|
+
/**
|
|
366
|
+
* The responses chat instance
|
|
367
|
+
* @internal
|
|
368
|
+
*/
|
|
369
|
+
responses?: ChatOpenAIResponses;
|
|
344
370
|
}
|
|
345
371
|
/**
|
|
346
372
|
* OpenAI chat model integration.
|
|
@@ -880,22 +906,25 @@ export interface ChatOpenAIFields extends BaseChatOpenAIFields {
|
|
|
880
906
|
*
|
|
881
907
|
* <br />
|
|
882
908
|
*/
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
909
|
+
declare class ChatOpenAI<CallOptions extends ChatOpenAICallOptions = ChatOpenAICallOptions> extends BaseChatOpenAI<CallOptions> {
|
|
910
|
+
protected fields?: ChatOpenAIFields | undefined;
|
|
911
|
+
/**
|
|
912
|
+
* Whether to use the responses API for all requests. If `false` the responses API will be used
|
|
913
|
+
* only when required in order to fulfill the request.
|
|
914
|
+
*/
|
|
915
|
+
useResponsesApi: boolean;
|
|
916
|
+
protected responses: ChatOpenAIResponses;
|
|
917
|
+
protected completions: ChatOpenAICompletions;
|
|
918
|
+
get lc_serializable_keys(): string[];
|
|
919
|
+
constructor(fields?: ChatOpenAIFields | undefined);
|
|
920
|
+
protected _useResponsesApi(options: this["ParsedCallOptions"] | undefined): boolean | undefined;
|
|
921
|
+
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
922
|
+
invocationParams(options?: this["ParsedCallOptions"]): ChatCompletionsInvocationParams | ChatResponsesInvocationParams;
|
|
923
|
+
/** @ignore */
|
|
924
|
+
_generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
925
|
+
_streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
926
|
+
withConfig(config: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;
|
|
901
927
|
}
|
|
928
|
+
//#endregion
|
|
929
|
+
export { BaseChatOpenAI, BaseChatOpenAICallOptions, BaseChatOpenAIFields, ChatOpenAI, ChatOpenAICallOptions, ChatOpenAICompletions, ChatOpenAICompletionsCallOptions, ChatOpenAIFields, ChatOpenAIResponses, ChatOpenAIResponsesCallOptions };
|
|
930
|
+
//# sourceMappingURL=chat_models.d.ts.map
|