@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.
Files changed (162) hide show
  1. package/README.md +8 -8
  2. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  3. package/dist/azure/chat_models.cjs +661 -808
  4. package/dist/azure/chat_models.cjs.map +1 -0
  5. package/dist/azure/chat_models.d.cts +449 -0
  6. package/dist/azure/chat_models.d.cts.map +1 -0
  7. package/dist/azure/chat_models.d.ts +32 -28
  8. package/dist/azure/chat_models.d.ts.map +1 -0
  9. package/dist/azure/chat_models.js +660 -804
  10. package/dist/azure/chat_models.js.map +1 -0
  11. package/dist/azure/embeddings.cjs +81 -130
  12. package/dist/azure/embeddings.cjs.map +1 -0
  13. package/dist/azure/embeddings.d.cts +27 -0
  14. package/dist/azure/embeddings.d.cts.map +1 -0
  15. package/dist/azure/embeddings.d.ts +25 -20
  16. package/dist/azure/embeddings.d.ts.map +1 -0
  17. package/dist/azure/embeddings.js +80 -126
  18. package/dist/azure/embeddings.js.map +1 -0
  19. package/dist/azure/llms.cjs +109 -168
  20. package/dist/azure/llms.cjs.map +1 -0
  21. package/dist/azure/llms.d.cts +33 -0
  22. package/dist/azure/llms.d.cts.map +1 -0
  23. package/dist/azure/llms.d.ts +31 -25
  24. package/dist/azure/llms.d.ts.map +1 -0
  25. package/dist/azure/llms.js +108 -164
  26. package/dist/azure/llms.js.map +1 -0
  27. package/dist/chat_models.cjs +1951 -2763
  28. package/dist/chat_models.cjs.map +1 -0
  29. package/dist/chat_models.d.cts +930 -0
  30. package/dist/chat_models.d.cts.map +1 -0
  31. package/dist/chat_models.d.ts +365 -336
  32. package/dist/chat_models.d.ts.map +1 -0
  33. package/dist/chat_models.js +1946 -2753
  34. package/dist/chat_models.js.map +1 -0
  35. package/dist/embeddings.cjs +136 -193
  36. package/dist/embeddings.cjs.map +1 -0
  37. package/dist/embeddings.d.cts +115 -0
  38. package/dist/embeddings.d.cts.map +1 -0
  39. package/dist/embeddings.d.ts +88 -81
  40. package/dist/embeddings.d.ts.map +1 -0
  41. package/dist/embeddings.js +134 -188
  42. package/dist/embeddings.js.map +1 -0
  43. package/dist/index.cjs +47 -34
  44. package/dist/index.d.cts +16 -0
  45. package/dist/index.d.ts +16 -13
  46. package/dist/index.js +17 -13
  47. package/dist/langchain-core/dist/types/_internal.d.cts +11 -0
  48. package/dist/langchain-core/dist/types/_internal.d.cts.map +1 -0
  49. package/dist/langchain-core/dist/types/_internal.d.ts +11 -0
  50. package/dist/langchain-core/dist/types/_internal.d.ts.map +1 -0
  51. package/dist/langchain-core/dist/utils/stream.d.cts +26 -0
  52. package/dist/langchain-core/dist/utils/stream.d.cts.map +1 -0
  53. package/dist/langchain-core/dist/utils/stream.d.ts +26 -0
  54. package/dist/langchain-core/dist/utils/stream.d.ts.map +1 -0
  55. package/dist/llms.cjs +312 -468
  56. package/dist/llms.cjs.map +1 -0
  57. package/dist/llms.d.cts +123 -0
  58. package/dist/llms.d.cts.map +1 -0
  59. package/dist/llms.d.ts +93 -87
  60. package/dist/llms.d.ts.map +1 -0
  61. package/dist/llms.js +309 -462
  62. package/dist/llms.js.map +1 -0
  63. package/dist/tools/custom.cjs +25 -26
  64. package/dist/tools/custom.cjs.map +1 -0
  65. package/dist/tools/custom.d.cts +10 -0
  66. package/dist/tools/custom.d.cts.map +1 -0
  67. package/dist/tools/custom.d.ts +8 -3
  68. package/dist/tools/custom.d.ts.map +1 -0
  69. package/dist/tools/custom.js +24 -23
  70. package/dist/tools/custom.js.map +1 -0
  71. package/dist/tools/dalle.cjs +104 -194
  72. package/dist/tools/dalle.cjs.map +1 -0
  73. package/dist/tools/dalle.d.cts +123 -0
  74. package/dist/tools/dalle.d.cts.map +1 -0
  75. package/dist/tools/dalle.d.ts +111 -104
  76. package/dist/tools/dalle.d.ts.map +1 -0
  77. package/dist/tools/dalle.js +102 -189
  78. package/dist/tools/dalle.js.map +1 -0
  79. package/dist/tools/index.cjs +1 -17
  80. package/dist/tools/index.js +1 -1
  81. package/dist/types.d.cts +263 -0
  82. package/dist/types.d.cts.map +1 -0
  83. package/dist/types.d.ts +244 -234
  84. package/dist/types.d.ts.map +1 -0
  85. package/dist/utils/azure.cjs +86 -47
  86. package/dist/utils/azure.cjs.map +1 -0
  87. package/dist/utils/azure.d.cts +76 -0
  88. package/dist/utils/azure.d.cts.map +1 -0
  89. package/dist/utils/azure.d.ts +51 -9
  90. package/dist/utils/azure.d.ts.map +1 -0
  91. package/dist/utils/azure.js +85 -45
  92. package/dist/utils/azure.js.map +1 -0
  93. package/dist/utils/client.cjs +25 -0
  94. package/dist/utils/client.cjs.map +1 -0
  95. package/dist/utils/client.d.cts +5 -0
  96. package/dist/utils/client.d.cts.map +1 -0
  97. package/dist/utils/client.d.ts +5 -0
  98. package/dist/utils/client.d.ts.map +1 -0
  99. package/dist/utils/client.js +24 -0
  100. package/dist/utils/client.js.map +1 -0
  101. package/dist/utils/errors.cjs +9 -8
  102. package/dist/utils/errors.cjs.map +1 -0
  103. package/dist/utils/errors.js +9 -6
  104. package/dist/utils/errors.js.map +1 -0
  105. package/dist/utils/message_inputs.cjs +139 -0
  106. package/dist/utils/message_inputs.cjs.map +1 -0
  107. package/dist/utils/message_inputs.d.cts +9 -0
  108. package/dist/utils/message_inputs.d.cts.map +1 -0
  109. package/dist/utils/message_inputs.d.ts +9 -0
  110. package/dist/utils/message_inputs.d.ts.map +1 -0
  111. package/dist/utils/message_inputs.js +137 -0
  112. package/dist/utils/message_inputs.js.map +1 -0
  113. package/dist/utils/misc.cjs +30 -0
  114. package/dist/utils/misc.cjs.map +1 -0
  115. package/dist/utils/misc.d.cts +9 -0
  116. package/dist/utils/misc.d.cts.map +1 -0
  117. package/dist/utils/misc.d.ts +9 -0
  118. package/dist/utils/misc.d.ts.map +1 -0
  119. package/dist/utils/misc.js +27 -0
  120. package/dist/utils/misc.js.map +1 -0
  121. package/dist/utils/output.cjs +74 -0
  122. package/dist/utils/output.cjs.map +1 -0
  123. package/dist/utils/output.js +72 -0
  124. package/dist/utils/output.js.map +1 -0
  125. package/dist/utils/prompts.cjs +39 -38
  126. package/dist/utils/prompts.cjs.map +1 -0
  127. package/dist/utils/prompts.d.cts +42 -0
  128. package/dist/utils/prompts.d.cts.map +1 -0
  129. package/dist/utils/prompts.d.ts +10 -4
  130. package/dist/utils/prompts.d.ts.map +1 -0
  131. package/dist/utils/prompts.js +40 -36
  132. package/dist/utils/prompts.js.map +1 -0
  133. package/dist/utils/standard.cjs +113 -0
  134. package/dist/utils/standard.cjs.map +1 -0
  135. package/dist/utils/standard.js +111 -0
  136. package/dist/utils/standard.js.map +1 -0
  137. package/dist/utils/tools.cjs +150 -127
  138. package/dist/utils/tools.cjs.map +1 -0
  139. package/dist/utils/tools.d.cts +13 -0
  140. package/dist/utils/tools.d.cts.map +1 -0
  141. package/dist/utils/tools.d.ts +12 -42
  142. package/dist/utils/tools.d.ts.map +1 -0
  143. package/dist/utils/tools.js +146 -123
  144. package/dist/utils/tools.js.map +1 -0
  145. package/package.json +33 -41
  146. package/dist/tools/index.d.ts +0 -1
  147. package/dist/types.cjs +0 -2
  148. package/dist/types.js +0 -1
  149. package/dist/utils/errors.d.ts +0 -2
  150. package/dist/utils/headers.cjs +0 -39
  151. package/dist/utils/headers.d.ts +0 -8
  152. package/dist/utils/headers.js +0 -35
  153. package/dist/utils/openai-format-fndef.cjs +0 -80
  154. package/dist/utils/openai-format-fndef.d.ts +0 -44
  155. package/dist/utils/openai-format-fndef.js +0 -77
  156. package/dist/utils/openai.cjs +0 -127
  157. package/dist/utils/openai.d.ts +0 -15
  158. package/dist/utils/openai.js +0 -119
  159. package/index.cjs +0 -1
  160. package/index.d.cts +0 -1
  161. package/index.d.ts +0 -1
  162. package/index.js +0 -1
@@ -1,275 +1,300 @@
1
- import { type ClientOptions, OpenAI as OpenAIClient } from "openai";
2
- import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
3
- import { AIMessageChunk, type BaseMessage, ChatMessageChunk, FunctionMessageChunk, HumanMessageChunk, SystemMessageChunk, ToolMessageChunk } from "@langchain/core/messages";
4
- import { ChatGenerationChunk, type ChatGeneration, type ChatResult } from "@langchain/core/outputs";
5
- import { BaseChatModel, type LangSmithParams, type BaseChatModelParams } from "@langchain/core/language_models/chat_models";
6
- import { type BaseFunctionCallOptions, type BaseLanguageModelInput, type StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
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 { type OpenAICallOptions, type OpenAIChatInput, type OpenAICoreRequestOptions, type ChatOpenAIResponseFormat, ChatOpenAIReasoningSummary, ResponseFormatConfiguration } from "./types.js";
10
- import { OpenAIToolChoice } from "./utils/openai.js";
11
- import { ChatOpenAIToolType, ResponsesTool, ResponsesToolChoice } from "./utils/tools.js";
11
+ import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
12
+
13
+ //#region src/chat_models.d.ts
12
14
  interface OpenAILLMOutput {
13
- tokenUsage: {
14
- completionTokens?: number;
15
- promptTokens?: number;
16
- totalTokens?: number;
17
- };
15
+ tokenUsage: {
16
+ completionTokens?: number;
17
+ promptTokens?: number;
18
+ totalTokens?: number;
19
+ };
18
20
  }
19
- export type { OpenAICallOptions, OpenAIChatInput };
20
- export declare function messageToOpenAIRole(message: BaseMessage): OpenAIClient.ChatCompletionRole;
21
- export declare function _convertMessagesToOpenAIParams(messages: BaseMessage[], model?: string): OpenAIClient.Chat.Completions.ChatCompletionMessageParam[];
22
- export interface BaseChatOpenAICallOptions extends OpenAICallOptions, BaseFunctionCallOptions {
23
- /**
24
- * A list of tools that the model may use to generate responses.
25
- * Each tool can be a function, a built-in tool, or a custom tool definition.
26
- * If not provided, the model will not use any tools.
27
- */
28
- tools?: ChatOpenAIToolType[];
29
- /**
30
- * Specifies which tool the model should use to respond.
31
- * Can be an {@link OpenAIToolChoice} or a {@link ResponsesToolChoice}.
32
- * If not set, the model will decide which tool to use automatically.
33
- */
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?: OpenAIClient.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<OpenAIClient.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?: OpenAIClient.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?: OpenAIClient.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?: OpenAIClient.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?: OpenAIClient.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;
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
- export interface BaseChatOpenAIFields extends Partial<OpenAIChatInput>, BaseChatModelParams {
120
- /**
121
- * Optional configuration options for the OpenAI client.
122
- */
123
- configuration?: ClientOptions;
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
- export declare abstract class BaseChatOpenAI<CallOptions extends BaseChatOpenAICallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements Partial<OpenAIChatInput> {
127
- temperature?: number;
128
- topP?: number;
129
- frequencyPenalty?: number;
130
- presencePenalty?: number;
131
- n?: number;
132
- logitBias?: Record<string, number>;
133
- model: string;
134
- modelKwargs?: OpenAIChatInput["modelKwargs"];
135
- stop?: string[];
136
- stopSequences?: string[];
137
- user?: string;
138
- timeout?: number;
139
- streaming: boolean;
140
- streamUsage: boolean;
141
- maxTokens?: number;
142
- logprobs?: boolean;
143
- topLogprobs?: number;
144
- apiKey?: string;
145
- organization?: string;
146
- __includeRawResponse?: boolean;
147
- /** @internal */
148
- client: OpenAIClient;
149
- /** @internal */
150
- clientConfig: ClientOptions;
151
- /**
152
- * Whether the model supports the `strict` argument when passing in tools.
153
- * If `undefined` the `strict` argument will not be passed to OpenAI.
154
- */
155
- supportsStrictToolCalling?: boolean;
156
- audio?: OpenAIClient.Chat.ChatCompletionAudioParam;
157
- modalities?: Array<OpenAIClient.Chat.ChatCompletionModality>;
158
- reasoning?: OpenAIClient.Reasoning;
159
- /**
160
- * Must be set to `true` in tenancies with Zero Data Retention. Setting to `true` will disable
161
- * output storage in the Responses API, but this DOES NOT enable Zero Data Retention in your
162
- * OpenAI organization or project. This must be configured directly with OpenAI.
163
- *
164
- * See:
165
- * https://help.openai.com/en/articles/10503543-data-residency-for-the-openai-api
166
- * https://platform.openai.com/docs/api-reference/responses/create#responses-create-store
167
- *
168
- * @default false
169
- */
170
- zdrEnabled?: boolean | undefined;
171
- /**
172
- * Service tier to use for this request. Can be "auto", "default", or "flex" or "priority".
173
- * Specifies the service tier for prioritization and latency optimization.
174
- */
175
- service_tier?: OpenAIClient.Chat.ChatCompletionCreateParams["service_tier"];
176
- /**
177
- * Used by OpenAI to cache responses for similar requests to optimize your cache
178
- * hit rates.
179
- * [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
180
- */
181
- promptCacheKey: string;
182
- protected defaultOptions: CallOptions;
183
- _llmType(): string;
184
- static lc_name(): string;
185
- get callKeys(): string[];
186
- lc_serializable: boolean;
187
- get lc_secrets(): {
188
- [key: string]: string;
189
- } | undefined;
190
- get lc_aliases(): Record<string, string>;
191
- get lc_serializable_keys(): string[];
192
- getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
193
- /** @ignore */
194
- _identifyingParams(): Omit<OpenAIClient.Chat.ChatCompletionCreateParams, "messages"> & {
195
- model_name: string;
196
- } & ClientOptions;
197
- /**
198
- * Get the identifying parameters for the model
199
- */
200
- identifyingParams(): Omit<OpenAIClient.Chat.Completions.ChatCompletionCreateParams, "messages"> & {
201
- model_name: string;
202
- } & ClientOptions;
203
- constructor(fields?: BaseChatOpenAIFields);
204
- /**
205
- * Returns backwards compatible reasoning parameters from constructor params and call options
206
- * @internal
207
- */
208
- protected _getReasoningParams(options?: this["ParsedCallOptions"]): OpenAIClient.Reasoning | undefined;
209
- /**
210
- * Returns an openai compatible response format from a set of options
211
- * @internal
212
- */
213
- protected _getResponseFormat(resFormat?: CallOptions["response_format"]): ResponseFormatConfiguration | undefined;
214
- protected _combineCallOptions(additionalOptions?: this["ParsedCallOptions"]): this["ParsedCallOptions"];
215
- /** @internal */
216
- _getClientOptions(options: OpenAICoreRequestOptions | undefined): OpenAICoreRequestOptions;
217
- protected _convertChatOpenAIToolToCompletionsTool(tool: ChatOpenAIToolType, fields?: {
218
- strict?: boolean;
219
- }): OpenAIClient.ChatCompletionTool;
220
- bindTools(tools: ChatOpenAIToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;
221
- stream(input: BaseLanguageModelInput, options?: CallOptions): Promise<import("@langchain/core/utils/stream").IterableReadableStream<AIMessageChunk>>;
222
- invoke(input: BaseLanguageModelInput, options?: CallOptions): Promise<AIMessageChunk>;
223
- /** @ignore */
224
- _combineLLMOutput(...llmOutputs: OpenAILLMOutput[]): OpenAILLMOutput;
225
- getNumTokensFromMessages(messages: BaseMessage[]): Promise<{
226
- totalCount: number;
227
- countPerMessage: number[];
228
- }>;
229
- /** @internal */
230
- protected _getNumTokensFromGenerations(generations: ChatGeneration[]): Promise<number>;
231
- /** @internal */
232
- protected _getEstimatedTokenCountFromPrompt(messages: BaseMessage[], functions?: OpenAIClient.Chat.ChatCompletionCreateParams.Function[], function_call?: "none" | "auto" | OpenAIClient.Chat.ChatCompletionFunctionCallOption): Promise<number>;
233
- /** @internal */
234
- protected _getStructuredOutputMethod(config: StructuredOutputMethodOptions<boolean>): string | undefined;
235
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
236
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
237
- raw: BaseMessage;
238
- parsed: RunOutput;
239
- }>;
240
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
241
- raw: BaseMessage;
242
- parsed: RunOutput;
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
- controller: unknown;
292
+ controller: unknown;
247
293
  } ? never : T;
248
- type ResponsesCreate = OpenAIClient.Responses["create"];
249
- type ResponsesParse = OpenAIClient.Responses["parse"];
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
- export declare class ChatOpenAIResponses<CallOptions extends ChatOpenAIResponsesCallOptions = ChatOpenAIResponsesCallOptions> extends BaseChatOpenAI<CallOptions> {
281
- invocationParams(options?: this["ParsedCallOptions"]): ChatResponsesInvocationParams;
282
- _generate(messages: BaseMessage[], options: this["ParsedCallOptions"]): Promise<ChatResult>;
283
- _streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
284
- /**
285
- * Calls the Responses API with retry logic in case of failures.
286
- * @param request The request to send to the OpenAI API.
287
- * @param options Optional configuration for the API call.
288
- * @returns The response from the OpenAI API.
289
- */
290
- completionWithRetry(request: OpenAIClient.Responses.ResponseCreateParamsStreaming, requestOptions?: OpenAIClient.RequestOptions): Promise<AsyncIterable<OpenAIClient.Responses.ResponseStreamEvent>>;
291
- completionWithRetry(request: OpenAIClient.Responses.ResponseCreateParamsNonStreaming, requestOptions?: OpenAIClient.RequestOptions): Promise<OpenAIClient.Responses.Response>;
292
- /** @internal */
293
- protected _convertResponsesMessageToBaseMessage(response: ResponsesCreateInvoke | ResponsesParseInvoke): BaseMessage;
294
- /** @internal */
295
- protected _convertResponsesDeltaToBaseMessageChunk(chunk: OpenAIClient.Responses.ResponseStreamEvent): ChatGenerationChunk | null;
296
- /** @internal */
297
- protected _convertMessagesToResponsesParams(messages: BaseMessage[]): (OpenAIClient.Responses.ResponseReasoningItem | OpenAIClient.Responses.EasyInputMessage | OpenAIClient.Responses.ResponseInputItem.Message | OpenAIClient.Responses.ResponseOutputMessage | OpenAIClient.Responses.ResponseFileSearchToolCall | OpenAIClient.Responses.ResponseComputerToolCall | OpenAIClient.Responses.ResponseInputItem.ComputerCallOutput | OpenAIClient.Responses.ResponseFunctionWebSearch | OpenAIClient.Responses.ResponseFunctionToolCall | OpenAIClient.Responses.ResponseInputItem.FunctionCallOutput | OpenAIClient.Responses.ResponseInputItem.ImageGenerationCall | OpenAIClient.Responses.ResponseCodeInterpreterToolCall | OpenAIClient.Responses.ResponseInputItem.LocalShellCall | OpenAIClient.Responses.ResponseInputItem.LocalShellCallOutput | OpenAIClient.Responses.ResponseInputItem.McpListTools | OpenAIClient.Responses.ResponseInputItem.McpApprovalRequest | OpenAIClient.Responses.ResponseInputItem.McpApprovalResponse | OpenAIClient.Responses.ResponseInputItem.McpCall | OpenAIClient.Responses.ResponseCustomToolCallOutput | OpenAIClient.Responses.ResponseCustomToolCall | OpenAIClient.Responses.ResponseInputItem.ItemReference)[];
298
- /** @internal */
299
- protected _convertReasoningSummary(reasoning: ChatOpenAIReasoningSummary): OpenAIClient.Responses.ResponseReasoningItem;
300
- /** @internal */
301
- protected _reduceChatOpenAITools(tools: ChatOpenAIToolType[], fields: {
302
- stream?: boolean;
303
- strict?: boolean;
304
- }): ResponsesTool[];
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
- type ChatCompletionsInvocationParams = Omit<OpenAIClient.Chat.Completions.ChatCompletionCreateParams, "messages">;
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
- export declare class ChatOpenAICompletions<CallOptions extends ChatOpenAICompletionsCallOptions = ChatOpenAICompletionsCallOptions> extends BaseChatOpenAI<CallOptions> {
314
- /** @internal */
315
- invocationParams(options?: this["ParsedCallOptions"], extra?: {
316
- streaming?: boolean;
317
- }): ChatCompletionsInvocationParams;
318
- _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
319
- _streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
320
- completionWithRetry(request: OpenAIClient.Chat.ChatCompletionCreateParamsStreaming, requestOptions?: OpenAIClient.RequestOptions): Promise<AsyncIterable<OpenAIClient.Chat.Completions.ChatCompletionChunk>>;
321
- completionWithRetry(request: OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming, requestOptions?: OpenAIClient.RequestOptions): Promise<OpenAIClient.Chat.Completions.ChatCompletion>;
322
- /** @internal */
323
- protected _convertCompletionsMessageToBaseMessage(message: OpenAIClient.Chat.Completions.ChatCompletionMessage, rawResponse: OpenAIClient.Chat.Completions.ChatCompletion): BaseMessage;
324
- /** @internal */
325
- protected _convertCompletionsDeltaToBaseMessageChunk(delta: Record<string, any>, rawResponse: OpenAIClient.Chat.Completions.ChatCompletionChunk, defaultRole?: OpenAIClient.Chat.ChatCompletionRole): AIMessageChunk | HumanMessageChunk | SystemMessageChunk | FunctionMessageChunk | ToolMessageChunk | ChatMessageChunk;
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
- export type ChatOpenAICallOptions = ChatOpenAICompletionsCallOptions & ChatOpenAIResponsesCallOptions;
328
- export interface ChatOpenAIFields extends BaseChatOpenAIFields {
329
- /**
330
- * Whether to use the responses API for all requests. If `false` the responses API will be used
331
- * only when required in order to fulfill the request.
332
- */
333
- useResponsesApi?: boolean;
334
- /**
335
- * The completions chat instance
336
- * @internal
337
- */
338
- completions?: ChatOpenAICompletions;
339
- /**
340
- * The responses chat instance
341
- * @internal
342
- */
343
- responses?: ChatOpenAIResponses;
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
- export declare class ChatOpenAI<CallOptions extends ChatOpenAICallOptions = ChatOpenAICallOptions> extends BaseChatOpenAI<CallOptions> {
884
- protected fields?: ChatOpenAIFields | undefined;
885
- /**
886
- * Whether to use the responses API for all requests. If `false` the responses API will be used
887
- * only when required in order to fulfill the request.
888
- */
889
- useResponsesApi: boolean;
890
- protected responses: ChatOpenAIResponses;
891
- protected completions: ChatOpenAICompletions;
892
- get lc_serializable_keys(): string[];
893
- constructor(fields?: ChatOpenAIFields | undefined);
894
- protected _useResponsesApi(options: this["ParsedCallOptions"] | undefined): boolean | undefined;
895
- getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
896
- invocationParams(options?: this["ParsedCallOptions"]): ChatResponsesInvocationParams | ChatCompletionsInvocationParams;
897
- /** @ignore */
898
- _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
899
- _streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
900
- withConfig(config: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;
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