@langchain/openai 0.6.16 → 1.0.0-alpha.2
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 +1959 -2789
- package/dist/chat_models.cjs.map +1 -0
- package/dist/chat_models.d.cts +931 -0
- package/dist/chat_models.d.cts.map +1 -0
- package/dist/chat_models.d.ts +367 -351
- package/dist/chat_models.d.ts.map +1 -0
- package/dist/chat_models.js +1954 -2779
- package/dist/chat_models.js.map +1 -0
- package/dist/embeddings.cjs +140 -206
- package/dist/embeddings.cjs.map +1 -0
- package/dist/embeddings.d.cts +120 -0
- package/dist/embeddings.d.cts.map +1 -0
- package/dist/embeddings.d.ts +93 -86
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +138 -201
- 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 -246
- 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 +32 -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 +29 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/output.cjs +106 -45
- package/dist/utils/output.cjs.map +1 -0
- package/dist/utils/output.js +104 -43
- 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 +315 -0
- package/dist/utils/standard.cjs.map +1 -0
- package/dist/utils/standard.js +313 -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 +51 -60
- 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/dist/utils/output.d.ts +0 -11
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,265 +1,263 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { TiktokenModel } from "js-tiktoken/lite";
|
|
4
|
-
import type { BaseLanguageModelCallOptions } from "@langchain/core/language_models/base";
|
|
1
|
+
import { OpenAI as OpenAI$1 } from "openai";
|
|
2
|
+
import { BaseLanguageModelCallOptions } from "@langchain/core/language_models/base";
|
|
5
3
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
6
|
-
|
|
4
|
+
import { ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatText, ResponseFormatTextGrammar, ResponseFormatTextPython } from "openai/resources/shared";
|
|
5
|
+
import { TiktokenModel } from "js-tiktoken/lite";
|
|
6
|
+
|
|
7
|
+
//#region src/types.d.ts
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* @see https://platform.openai.com/docs/models
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
12
|
+
type OpenAIChatModelId = OpenAI$1.ChatModel | (string & NonNullable<unknown>);
|
|
13
|
+
type OpenAIVerbosityParam = "low" | "medium" | "high" | null;
|
|
14
|
+
declare interface OpenAIBaseInput {
|
|
15
|
+
/** Sampling temperature to use */
|
|
16
|
+
temperature: number;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum number of tokens to generate in the completion. -1 returns as many
|
|
19
|
+
* tokens as possible given the prompt and the model's maximum context size.
|
|
20
|
+
*/
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum number of tokens to generate in the completion. -1 returns as many
|
|
24
|
+
* tokens as possible given the prompt and the model's maximum context size.
|
|
25
|
+
* Alias for `maxTokens` for reasoning models.
|
|
26
|
+
*/
|
|
27
|
+
maxCompletionTokens?: number;
|
|
28
|
+
/** Total probability mass of tokens to consider at each step */
|
|
29
|
+
topP: number;
|
|
30
|
+
/** Penalizes repeated tokens according to frequency */
|
|
31
|
+
frequencyPenalty: number;
|
|
32
|
+
/** Penalizes repeated tokens */
|
|
33
|
+
presencePenalty: number;
|
|
34
|
+
/** Number of completions to generate for each prompt */
|
|
35
|
+
n: number;
|
|
36
|
+
/** Dictionary used to adjust the probability of specific tokens being generated */
|
|
37
|
+
logitBias?: Record<string, number>;
|
|
38
|
+
/** Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse. */
|
|
39
|
+
user?: string;
|
|
40
|
+
/** Whether to stream the results or not. Enabling disables tokenUsage reporting */
|
|
41
|
+
streaming: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether or not to include token usage data in streamed chunks.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
streamUsage?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Model name to use
|
|
49
|
+
* Alias for `model`
|
|
50
|
+
* @deprecated Use "model" instead.
|
|
51
|
+
*/
|
|
52
|
+
modelName: string;
|
|
53
|
+
/** Model name to use */
|
|
54
|
+
model: OpenAIChatModelId;
|
|
55
|
+
/** Holds any additional parameters that are valid to pass to {@link
|
|
56
|
+
* https://platform.openai.com/docs/api-reference/completions/create |
|
|
57
|
+
* `openai.createCompletion`} that are not explicitly specified on this class.
|
|
58
|
+
*/
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
modelKwargs?: Record<string, any>;
|
|
61
|
+
/**
|
|
62
|
+
* List of stop words to use when generating
|
|
63
|
+
* Alias for `stopSequences`
|
|
64
|
+
*/
|
|
65
|
+
stop?: string[];
|
|
66
|
+
/** List of stop words to use when generating */
|
|
67
|
+
stopSequences?: string[];
|
|
68
|
+
/**
|
|
69
|
+
* Timeout to use when making requests to OpenAI.
|
|
70
|
+
*/
|
|
71
|
+
timeout?: number;
|
|
72
|
+
/**
|
|
73
|
+
* API key to use when making requests to OpenAI. Defaults to the value of
|
|
74
|
+
* `OPENAI_API_KEY` environment variable.
|
|
75
|
+
* Alias for `apiKey`
|
|
76
|
+
*/
|
|
77
|
+
openAIApiKey?: string;
|
|
78
|
+
/**
|
|
79
|
+
* API key to use when making requests to OpenAI. Defaults to the value of
|
|
80
|
+
* `OPENAI_API_KEY` environment variable.
|
|
81
|
+
*/
|
|
82
|
+
apiKey?: string;
|
|
83
|
+
/**
|
|
84
|
+
* The verbosity of the model's response.
|
|
85
|
+
*/
|
|
86
|
+
verbosity?: OpenAIVerbosityParam;
|
|
84
87
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
type OpenAICoreRequestOptions = OpenAI$1.RequestOptions;
|
|
89
|
+
interface OpenAICallOptions extends BaseLanguageModelCallOptions {
|
|
90
|
+
/**
|
|
91
|
+
* Additional options to pass to the underlying axios request.
|
|
92
|
+
*/
|
|
93
|
+
options?: OpenAICoreRequestOptions;
|
|
91
94
|
}
|
|
92
95
|
/**
|
|
93
96
|
* Input to OpenAI class.
|
|
94
97
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
declare interface OpenAIInput extends OpenAIBaseInput {
|
|
99
|
+
/** Generates `bestOf` completions server side and returns the "best" */
|
|
100
|
+
bestOf?: number;
|
|
101
|
+
/** Batch size to use when passing multiple documents to generate */
|
|
102
|
+
batchSize: number;
|
|
100
103
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
* Specifies the service tier for prioritization and latency optimization.
|
|
169
|
-
*/
|
|
170
|
-
service_tier?: OpenAIClient.Responses.ResponseCreateParams["service_tier"];
|
|
171
|
-
/**
|
|
172
|
-
* Used by OpenAI to cache responses for similar requests to optimize your cache
|
|
173
|
-
* hit rates. Replaces the `user` field.
|
|
174
|
-
* [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
|
|
175
|
-
*/
|
|
176
|
-
promptCacheKey?: string;
|
|
104
|
+
interface OpenAIChatInput extends OpenAIBaseInput {
|
|
105
|
+
/**
|
|
106
|
+
* Whether to return log probabilities of the output tokens or not.
|
|
107
|
+
* If true, returns the log probabilities of each output token returned in the content of message.
|
|
108
|
+
*/
|
|
109
|
+
logprobs?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* An integer between 0 and 5 specifying the number of most likely tokens to return at each token position,
|
|
112
|
+
* each with an associated log probability. logprobs must be set to true if this parameter is used.
|
|
113
|
+
*/
|
|
114
|
+
topLogprobs?: number;
|
|
115
|
+
/** ChatGPT messages to pass as a prefix to the prompt */
|
|
116
|
+
prefixMessages?: OpenAI$1.Chat.ChatCompletionMessageParam[];
|
|
117
|
+
/**
|
|
118
|
+
* Whether to include the raw OpenAI response in the output message's "additional_kwargs" field.
|
|
119
|
+
* Currently in experimental beta.
|
|
120
|
+
*/
|
|
121
|
+
__includeRawResponse?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether the model supports the `strict` argument when passing in tools.
|
|
124
|
+
* If `undefined` the `strict` argument will not be passed to OpenAI.
|
|
125
|
+
*/
|
|
126
|
+
supportsStrictToolCalling?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Output types that you would like the model to generate for this request. Most
|
|
129
|
+
* models are capable of generating text, which is the default:
|
|
130
|
+
*
|
|
131
|
+
* `["text"]`
|
|
132
|
+
*
|
|
133
|
+
* The `gpt-4o-audio-preview` model can also be used to
|
|
134
|
+
* [generate audio](https://platform.openai.com/docs/guides/audio). To request that
|
|
135
|
+
* this model generate both text and audio responses, you can use:
|
|
136
|
+
*
|
|
137
|
+
* `["text", "audio"]`
|
|
138
|
+
*/
|
|
139
|
+
modalities?: Array<OpenAI$1.Chat.ChatCompletionModality>;
|
|
140
|
+
/**
|
|
141
|
+
* Parameters for audio output. Required when audio output is requested with
|
|
142
|
+
* `modalities: ["audio"]`.
|
|
143
|
+
* [Learn more](https://platform.openai.com/docs/guides/audio).
|
|
144
|
+
*/
|
|
145
|
+
audio?: OpenAI$1.Chat.ChatCompletionAudioParam;
|
|
146
|
+
/**
|
|
147
|
+
* Options for reasoning models.
|
|
148
|
+
*
|
|
149
|
+
* Note that some options, like reasoning summaries, are only available when using the responses
|
|
150
|
+
* API. This option is ignored when not using a reasoning model.
|
|
151
|
+
*/
|
|
152
|
+
reasoning?: OpenAI$1.Reasoning;
|
|
153
|
+
/**
|
|
154
|
+
* Should be set to `true` in tenancies with Zero Data Retention
|
|
155
|
+
* @see https://platform.openai.com/docs/guides/your-data
|
|
156
|
+
*
|
|
157
|
+
* @default false
|
|
158
|
+
*/
|
|
159
|
+
zdrEnabled?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Service tier to use for this request. Can be "auto", "default", or "flex" or "priority".
|
|
162
|
+
* Specifies the service tier for prioritization and latency optimization.
|
|
163
|
+
*/
|
|
164
|
+
service_tier?: OpenAI$1.Responses.ResponseCreateParams["service_tier"];
|
|
165
|
+
/**
|
|
166
|
+
* Used by OpenAI to cache responses for similar requests to optimize your cache
|
|
167
|
+
* hit rates. Replaces the `user` field.
|
|
168
|
+
* [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
|
|
169
|
+
*/
|
|
170
|
+
promptCacheKey?: string;
|
|
177
171
|
}
|
|
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
|
-
|
|
172
|
+
interface AzureOpenAIInput {
|
|
173
|
+
/**
|
|
174
|
+
* API version to use when making requests to Azure OpenAI.
|
|
175
|
+
*/
|
|
176
|
+
azureOpenAIApiVersion?: string;
|
|
177
|
+
/**
|
|
178
|
+
* API key to use when making requests to Azure OpenAI.
|
|
179
|
+
*/
|
|
180
|
+
azureOpenAIApiKey?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Azure OpenAI API instance name to use when making requests to Azure OpenAI.
|
|
183
|
+
* this is the name of the instance you created in the Azure portal.
|
|
184
|
+
* e.g. "my-openai-instance"
|
|
185
|
+
* this will be used in the endpoint URL: https://my-openai-instance.openai.azure.com/openai/deployments/{DeploymentName}/
|
|
186
|
+
*/
|
|
187
|
+
azureOpenAIApiInstanceName?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.
|
|
190
|
+
* This is the name of the deployment you created in the Azure portal.
|
|
191
|
+
* e.g. "my-openai-deployment"
|
|
192
|
+
* this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/
|
|
193
|
+
*/
|
|
194
|
+
azureOpenAIApiDeploymentName?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Azure OpenAI API deployment name to use for embedding when making requests to Azure OpenAI.
|
|
197
|
+
* This is the name of the deployment you created in the Azure portal.
|
|
198
|
+
* This will fallback to azureOpenAIApiDeploymentName if not provided.
|
|
199
|
+
* e.g. "my-openai-deployment"
|
|
200
|
+
* this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/
|
|
201
|
+
*/
|
|
202
|
+
azureOpenAIApiEmbeddingsDeploymentName?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.
|
|
205
|
+
* Completions are only available for gpt-3.5-turbo and text-davinci-003 deployments.
|
|
206
|
+
* This is the name of the deployment you created in the Azure portal.
|
|
207
|
+
* This will fallback to azureOpenAIApiDeploymentName if not provided.
|
|
208
|
+
* e.g. "my-openai-deployment"
|
|
209
|
+
* this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/
|
|
210
|
+
*/
|
|
211
|
+
azureOpenAIApiCompletionsDeploymentName?: string;
|
|
212
|
+
/**
|
|
213
|
+
* Custom base url for Azure OpenAI API. This is useful in case you have a deployment in another region.
|
|
214
|
+
* e.g. setting this value to "https://westeurope.api.cognitive.microsoft.com/openai/deployments"
|
|
215
|
+
* will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/
|
|
216
|
+
*/
|
|
217
|
+
azureOpenAIBasePath?: string;
|
|
218
|
+
/**
|
|
219
|
+
* Custom endpoint for Azure OpenAI API. This is useful in case you have a deployment in another region.
|
|
220
|
+
* e.g. setting this value to "https://westeurope.api.cognitive.microsoft.com/"
|
|
221
|
+
* will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/
|
|
222
|
+
*/
|
|
223
|
+
azureOpenAIEndpoint?: string;
|
|
224
|
+
/**
|
|
225
|
+
* A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory),
|
|
226
|
+
* which will be invoked on every request.
|
|
227
|
+
*/
|
|
228
|
+
azureADTokenProvider?: () => Promise<string>;
|
|
235
229
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
230
|
+
interface AzureOpenAIChatInput extends OpenAIChatInput, AzureOpenAIInput {
|
|
231
|
+
openAIApiKey?: string;
|
|
232
|
+
openAIApiVersion?: string;
|
|
233
|
+
openAIBasePath?: string;
|
|
234
|
+
deploymentName?: string;
|
|
241
235
|
}
|
|
242
236
|
type ChatOpenAIResponseFormatJSONSchema = Omit<ResponseFormatJSONSchema, "json_schema"> & {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
237
|
+
json_schema: Omit<ResponseFormatJSONSchema["json_schema"], "schema"> & {
|
|
238
|
+
/**
|
|
239
|
+
* The schema for the response format, described as a JSON Schema object
|
|
240
|
+
* or a Zod object.
|
|
241
|
+
*/
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
243
|
+
schema: Record<string, any> | InteropZodObject;
|
|
244
|
+
};
|
|
250
245
|
};
|
|
251
246
|
/**
|
|
252
247
|
* The summary of a model's reasoning step.
|
|
253
248
|
*/
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
249
|
+
type ChatOpenAIReasoningSummary = Omit<OpenAI$1.Responses.ResponseReasoningItem, "summary"> & {
|
|
250
|
+
/**
|
|
251
|
+
* The summary of the reasoning step. The index field will be populated if the response was
|
|
252
|
+
* streamed. This allows LangChain to recompose the reasoning summary output correctly when the
|
|
253
|
+
* AIMessage is used as an input for future generation requests.
|
|
254
|
+
*/
|
|
255
|
+
summary: Array<OpenAI$1.Responses.ResponseReasoningItem.Summary & {
|
|
256
|
+
index?: number;
|
|
257
|
+
}>;
|
|
263
258
|
};
|
|
264
|
-
|
|
265
|
-
|
|
259
|
+
type ChatOpenAIResponseFormat = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatTextGrammar | ResponseFormatTextPython | ChatOpenAIResponseFormatJSONSchema;
|
|
260
|
+
type ResponseFormatConfiguration = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatJSONSchema;
|
|
261
|
+
//#endregion
|
|
262
|
+
export { AzureOpenAIChatInput, AzureOpenAIInput, ChatOpenAIReasoningSummary, ChatOpenAIResponseFormat, OpenAIBaseInput, OpenAICallOptions, OpenAIChatInput, OpenAIChatModelId, OpenAICoreRequestOptions, OpenAIInput, OpenAIVerbosityParam, ResponseFormatConfiguration, type TiktokenModel };
|
|
263
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":["OpenAI","OpenAIClient","ResponseFormatText","ResponseFormatJSONObject","ResponseFormatJSONSchema","ResponseFormatTextPython","ResponseFormatTextGrammar","TiktokenModel","BaseLanguageModelCallOptions","InteropZodObject","OpenAIChatModelId","ChatModel","NonNullable","OpenAIVerbosityParam","OpenAIBaseInput","Record","OpenAICoreRequestOptions","RequestOptions","OpenAICallOptions","OpenAIInput","OpenAIChatInput","Chat","ChatCompletionMessageParam","ChatCompletionModality","Array","ChatCompletionAudioParam","Reasoning","Responses","ResponseCreateParams","AzureOpenAIInput","Promise","AzureOpenAIChatInput","ChatOpenAIResponseFormatJSONSchema","Omit","ChatOpenAIReasoningSummary","ResponseReasoningItem","Summary","ChatOpenAIResponseFormat","ResponseFormatConfiguration"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport type { ResponseFormatText, ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatTextPython, ResponseFormatTextGrammar } from \"openai/resources/shared\";\nimport { TiktokenModel } from \"js-tiktoken/lite\";\nimport type { BaseLanguageModelCallOptions } from \"@langchain/core/language_models/base\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\n// reexport this type from the included package so we can easily override and extend it if needed in the future\n// also makes it easier for folks to import this type without digging around into the dependent packages\nexport type { TiktokenModel };\n/**\n * @see https://platform.openai.com/docs/models\n */\nexport type OpenAIChatModelId = OpenAIClient.ChatModel | (string & NonNullable<unknown>);\nexport type OpenAIVerbosityParam = \"low\" | \"medium\" | \"high\" | null;\nexport declare interface OpenAIBaseInput {\n /** Sampling temperature to use */\n temperature: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n */\n maxTokens?: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n * Alias for `maxTokens` for reasoning models.\n */\n maxCompletionTokens?: number;\n /** Total probability mass of tokens to consider at each step */\n topP: number;\n /** Penalizes repeated tokens according to frequency */\n frequencyPenalty: number;\n /** Penalizes repeated tokens */\n presencePenalty: number;\n /** Number of completions to generate for each prompt */\n n: number;\n /** Dictionary used to adjust the probability of specific tokens being generated */\n logitBias?: Record<string, number>;\n /** Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse. */\n user?: string;\n /** Whether to stream the results or not. Enabling disables tokenUsage reporting */\n streaming: boolean;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Model name to use\n * Alias for `model`\n * @deprecated Use \"model\" instead.\n */\n modelName: string;\n /** Model name to use */\n model: OpenAIChatModelId;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://platform.openai.com/docs/api-reference/completions/create |\n * `openai.createCompletion`} that are not explicitly specified on this class.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelKwargs?: Record<string, any>;\n /**\n * List of stop words to use when generating\n * Alias for `stopSequences`\n */\n stop?: string[];\n /** List of stop words to use when generating */\n stopSequences?: string[];\n /**\n * Timeout to use when making requests to OpenAI.\n */\n timeout?: number;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n * Alias for `apiKey`\n */\n openAIApiKey?: string;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n */\n apiKey?: string;\n /**\n * The verbosity of the model's response.\n */\n verbosity?: OpenAIVerbosityParam;\n}\nexport type OpenAICoreRequestOptions = OpenAIClient.RequestOptions;\nexport interface OpenAICallOptions extends BaseLanguageModelCallOptions {\n /**\n * Additional options to pass to the underlying axios request.\n */\n options?: OpenAICoreRequestOptions;\n}\n/**\n * Input to OpenAI class.\n */\nexport declare interface OpenAIInput extends OpenAIBaseInput {\n /** Generates `bestOf` completions server side and returns the \"best\" */\n bestOf?: number;\n /** Batch size to use when passing multiple documents to generate */\n batchSize: number;\n}\nexport interface OpenAIChatInput extends OpenAIBaseInput {\n /**\n * Whether to return log probabilities of the output tokens or not.\n * If true, returns the log probabilities of each output token returned in the content of message.\n */\n logprobs?: boolean;\n /**\n * An integer between 0 and 5 specifying the number of most likely tokens to return at each token position,\n * each with an associated log probability. logprobs must be set to true if this parameter is used.\n */\n topLogprobs?: number;\n /** ChatGPT messages to pass as a prefix to the prompt */\n prefixMessages?: OpenAIClient.Chat.ChatCompletionMessageParam[];\n /**\n * Whether to include the raw OpenAI response in the output message's \"additional_kwargs\" field.\n * Currently in experimental beta.\n */\n __includeRawResponse?: boolean;\n /**\n * Whether the model supports the `strict` argument when passing in tools.\n * If `undefined` the `strict` argument will not be passed to OpenAI.\n */\n supportsStrictToolCalling?: boolean;\n /**\n * Output types that you would like the model to generate for this request. Most\n * models are capable of generating text, which is the default:\n *\n * `[\"text\"]`\n *\n * The `gpt-4o-audio-preview` model can also be used to\n * [generate audio](https://platform.openai.com/docs/guides/audio). To request that\n * this model generate both text and audio responses, you can use:\n *\n * `[\"text\", \"audio\"]`\n */\n modalities?: Array<OpenAIClient.Chat.ChatCompletionModality>;\n /**\n * Parameters for audio output. Required when audio output is requested with\n * `modalities: [\"audio\"]`.\n * [Learn more](https://platform.openai.com/docs/guides/audio).\n */\n audio?: OpenAIClient.Chat.ChatCompletionAudioParam;\n /**\n * Options for reasoning models.\n *\n * Note that some options, like reasoning summaries, are only available when using the responses\n * API. This option is ignored when not using a reasoning model.\n */\n reasoning?: OpenAIClient.Reasoning;\n /**\n * Should be set to `true` in tenancies with Zero Data Retention\n * @see https://platform.openai.com/docs/guides/your-data\n *\n * @default false\n */\n zdrEnabled?: boolean;\n /**\n * Service tier to use for this request. Can be \"auto\", \"default\", or \"flex\" or \"priority\".\n * Specifies the service tier for prioritization and latency optimization.\n */\n service_tier?: OpenAIClient.Responses.ResponseCreateParams[\"service_tier\"];\n /**\n * Used by OpenAI to cache responses for similar requests to optimize your cache\n * hit rates. Replaces the `user` field.\n * [Learn more](https://platform.openai.com/docs/guides/prompt-caching).\n */\n promptCacheKey?: string;\n}\nexport interface AzureOpenAIInput {\n /**\n * API version to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiVersion?: string;\n /**\n * API key to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiKey?: string;\n /**\n * Azure OpenAI API instance name to use when making requests to Azure OpenAI.\n * this is the name of the instance you created in the Azure portal.\n * e.g. \"my-openai-instance\"\n * this will be used in the endpoint URL: https://my-openai-instance.openai.azure.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIApiInstanceName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for embedding when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiEmbeddingsDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * Completions are only available for gpt-3.5-turbo and text-davinci-003 deployments.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiCompletionsDeploymentName?: string;\n /**\n * Custom base url for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/openai/deployments\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIBasePath?: string;\n /**\n * Custom endpoint for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIEndpoint?: string;\n /**\n * A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory),\n * which will be invoked on every request.\n */\n azureADTokenProvider?: () => Promise<string>;\n}\nexport interface AzureOpenAIChatInput extends OpenAIChatInput, AzureOpenAIInput {\n openAIApiKey?: string;\n openAIApiVersion?: string;\n openAIBasePath?: string;\n deploymentName?: string;\n}\ntype ChatOpenAIResponseFormatJSONSchema = Omit<ResponseFormatJSONSchema, \"json_schema\"> & {\n json_schema: Omit<ResponseFormatJSONSchema[\"json_schema\"], \"schema\"> & {\n /**\n * The schema for the response format, described as a JSON Schema object\n * or a Zod object.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any> | InteropZodObject;\n };\n};\n/**\n * The summary of a model's reasoning step.\n */\nexport type ChatOpenAIReasoningSummary = Omit<OpenAIClient.Responses.ResponseReasoningItem, \"summary\"> & {\n /**\n * The summary of the reasoning step. The index field will be populated if the response was\n * streamed. This allows LangChain to recompose the reasoning summary output correctly when the\n * AIMessage is used as an input for future generation requests.\n */\n summary: Array<OpenAIClient.Responses.ResponseReasoningItem.Summary & {\n index?: number;\n }>;\n};\nexport type ChatOpenAIResponseFormat = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatTextGrammar | ResponseFormatTextPython | ChatOpenAIResponseFormatJSONSchema;\nexport type ResponseFormatConfiguration = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatJSONSchema;\n"],"mappings":";;;;;;;;;;;AAW8E,KAAlEU,iBAAAA,GAAoBT,QAAAA,CAAaU,SAAiC,GAAA,CAAA,MAAA,GAAXC,WAAW,CAAA,OAAA,CAAA,CAAA;AAClEC,KAAAA,oBAAAA,GAAoB,KAAA,GAAA,QAAA,GAAA,MAAA,GAAA,IAAA;AACPC,kBAAAA,eAAAA,CAAe;EAAA;EAAA,WAuBxBC,EAAAA,MAAAA;EAAM;;;AAiDc;EAExBC,SAAAA,CAAAA,EAAAA,MAAAA;EACKE;;;;AAAsD;EAS9CC,mBAAW,CAAA,EAAA,MAASL;EAM5BM;EAAe,IAAA,EAAA,MAAA;EAAA;EAYiC,gBAuB7BC,EAAKE,MAAAA;EAAsB;EAAzC,eAMGF,EAAKI,MAAAA;EAAwB;EAOhB,CAAA,EAYnBxB,MAAAA;EAA2C;EA5DN,SAAA,CAAA,EAnExCc,MAmEwC,CAAA,MAAA,EAAA,MAAA,CAAA;EAoEvCc;EA0DAE,IAAAA,CAAAA,EAAAA,MAAAA;EAAoB;EAAA,SAASX,EAAAA,OAAAA;EAAe;AAAkB;AAK9E;;EACsC,WAAQhB,CAAAA,EAAAA,OAAAA;EAAwB;;;;;EAOjB,SAAA,EAAA,MAAA;EAM1C8B;EAA0B,KAAA,EAnM3BxB,iBAmM2B;EAAA;;;;EAMpB;EAIN2B,WAAAA,CAAAA,EAvMMtB,MAuMNsB,CAAAA,MAAwB,EAAA,GAAA,CAAA;EAAA;;;;EAA4E,IAAGhC,CAAAA,EAAAA,MAAAA,EAAAA;EAAwB;EAAqC,aAAA,CAAA,EAAA,MAAA,EAAA;EACpKiC;;;EAAgD,OAAGnC,CAAAA,EAAAA,MAAAA;EAAwB;AAA2B;;;;;;;;;;;;;cA9KlGU;;KAEJG,wBAAAA,GAA2Bf,QAAAA,CAAagB;UACnCC,iBAAAA,SAA0BV;;;;YAI7BQ;;;;;kBAKWG,WAAAA,SAAoBL;;;;;;UAM5BM,eAAAA,SAAwBN;;;;;;;;;;;;mBAYpBb,QAAAA,CAAaoB,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;eAuBtBE,MAAMvB,QAAAA,CAAaoB,IAAAA,CAAKE;;;;;;UAM7BtB,QAAAA,CAAaoB,IAAAA,CAAKI;;;;;;;cAOdxB,QAAAA,CAAayB;;;;;;;;;;;;iBAYVzB,QAAAA,CAAa0B,SAAAA,CAAUC;;;;;;;;UAQzBC,gBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAwDgBC;;UAEhBC,oBAAAA,SAA6BX,iBAAiBS;;;;;;KAM1DG,kCAAAA,GAAqCC,KAAK7B;eAC9B6B,KAAK7B;;;;;;YAMNW,sBAAsBN;;;;;;KAM1ByB,0BAAAA,GAA6BD,KAAKhC,QAAAA,CAAa0B,SAAAA,CAAUQ;;;;;;WAMxDX,MAAMvB,QAAAA,CAAa0B,SAAAA,CAAUQ,qBAAAA,CAAsBC;;;;KAIpDC,wBAAAA,GAA2BnC,qBAAqBC,2BAA2BG,4BAA4BD,2BAA2B2B;KAClIM,2BAAAA,GAA8BpC,qBAAqBC,2BAA2BC"}
|