@langchain/openai 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/azure/chat_models.cjs +47 -7
- package/dist/azure/chat_models.d.ts +2 -1
- package/dist/azure/chat_models.js +47 -7
- package/dist/azure/embeddings.cjs +70 -0
- package/dist/azure/embeddings.d.ts +14 -0
- package/dist/azure/embeddings.js +66 -0
- package/dist/azure/llms.cjs +46 -7
- package/dist/azure/llms.d.ts +2 -1
- package/dist/azure/llms.js +46 -7
- package/dist/chat_models.cjs +10 -3
- package/dist/chat_models.d.ts +4 -3
- package/dist/chat_models.js +10 -3
- package/dist/embeddings.cjs +10 -3
- package/dist/embeddings.d.ts +5 -4
- package/dist/embeddings.js +10 -3
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/llms.cjs +10 -3
- package/dist/llms.d.ts +4 -3
- package/dist/llms.js +10 -3
- package/dist/tests/azure/chat_models.int.test.d.ts +1 -0
- package/dist/tests/azure/chat_models.int.test.js +659 -0
- package/dist/tests/azure/embeddings.int.test.d.ts +1 -0
- package/dist/tests/azure/embeddings.int.test.js +67 -0
- package/dist/tests/azure/llms.int.test.d.ts +1 -0
- package/dist/tests/azure/llms.int.test.js +267 -0
- package/dist/types.d.ts +5 -0
- package/package.json +3 -2
package/dist/embeddings.js
CHANGED
|
@@ -76,6 +76,12 @@ export class OpenAIEmbeddings extends Embeddings {
|
|
|
76
76
|
writable: true,
|
|
77
77
|
value: void 0
|
|
78
78
|
});
|
|
79
|
+
Object.defineProperty(this, "azureADTokenProvider", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
value: void 0
|
|
84
|
+
});
|
|
79
85
|
Object.defineProperty(this, "azureOpenAIApiInstanceName", {
|
|
80
86
|
enumerable: true,
|
|
81
87
|
configurable: true,
|
|
@@ -117,8 +123,9 @@ export class OpenAIEmbeddings extends Embeddings {
|
|
|
117
123
|
getEnvironmentVariable("OPENAI_API_KEY");
|
|
118
124
|
const azureApiKey = fieldsWithDefaults?.azureOpenAIApiKey ??
|
|
119
125
|
getEnvironmentVariable("AZURE_OPENAI_API_KEY");
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
this.azureADTokenProvider = fields?.azureADTokenProvider ?? undefined;
|
|
127
|
+
if (!azureApiKey && !apiKey && !this.azureADTokenProvider) {
|
|
128
|
+
throw new Error("OpenAI or Azure OpenAI API key or Token Provider not found");
|
|
122
129
|
}
|
|
123
130
|
const azureApiInstanceName = fieldsWithDefaults?.azureOpenAIApiInstanceName ??
|
|
124
131
|
getEnvironmentVariable("AZURE_OPENAI_API_INSTANCE_NAME");
|
|
@@ -147,7 +154,7 @@ export class OpenAIEmbeddings extends Embeddings {
|
|
|
147
154
|
this.azureOpenAIApiKey = azureApiKey;
|
|
148
155
|
this.azureOpenAIApiInstanceName = azureApiInstanceName;
|
|
149
156
|
this.azureOpenAIApiDeploymentName = azureApiDeploymentName;
|
|
150
|
-
if (this.azureOpenAIApiKey) {
|
|
157
|
+
if (this.azureOpenAIApiKey || this.azureADTokenProvider) {
|
|
151
158
|
if (!this.azureOpenAIApiInstanceName && !this.azureOpenAIBasePath) {
|
|
152
159
|
throw new Error("Azure OpenAI API instance name not found");
|
|
153
160
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ __exportStar(require("./chat_models.cjs"), exports);
|
|
|
22
22
|
__exportStar(require("./azure/chat_models.cjs"), exports);
|
|
23
23
|
__exportStar(require("./llms.cjs"), exports);
|
|
24
24
|
__exportStar(require("./azure/llms.cjs"), exports);
|
|
25
|
+
__exportStar(require("./azure/embeddings.cjs"), exports);
|
|
25
26
|
__exportStar(require("./embeddings.cjs"), exports);
|
|
26
27
|
__exportStar(require("./types.cjs"), exports);
|
|
27
28
|
__exportStar(require("./utils/openai.cjs"), exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./chat_models.js";
|
|
|
3
3
|
export * from "./azure/chat_models.js";
|
|
4
4
|
export * from "./llms.js";
|
|
5
5
|
export * from "./azure/llms.js";
|
|
6
|
+
export * from "./azure/embeddings.js";
|
|
6
7
|
export * from "./embeddings.js";
|
|
7
8
|
export * from "./types.js";
|
|
8
9
|
export * from "./utils/openai.js";
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./chat_models.js";
|
|
|
3
3
|
export * from "./azure/chat_models.js";
|
|
4
4
|
export * from "./llms.js";
|
|
5
5
|
export * from "./azure/llms.js";
|
|
6
|
+
export * from "./azure/embeddings.js";
|
|
6
7
|
export * from "./embeddings.js";
|
|
7
8
|
export * from "./types.js";
|
|
8
9
|
export * from "./utils/openai.js";
|
package/dist/llms.cjs
CHANGED
|
@@ -211,6 +211,12 @@ class OpenAI extends llms_1.BaseLLM {
|
|
|
211
211
|
writable: true,
|
|
212
212
|
value: void 0
|
|
213
213
|
});
|
|
214
|
+
Object.defineProperty(this, "azureADTokenProvider", {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
configurable: true,
|
|
217
|
+
writable: true,
|
|
218
|
+
value: void 0
|
|
219
|
+
});
|
|
214
220
|
Object.defineProperty(this, "azureOpenAIApiInstanceName", {
|
|
215
221
|
enumerable: true,
|
|
216
222
|
configurable: true,
|
|
@@ -256,8 +262,9 @@ class OpenAI extends llms_1.BaseLLM {
|
|
|
256
262
|
this.azureOpenAIApiKey =
|
|
257
263
|
fields?.azureOpenAIApiKey ??
|
|
258
264
|
(0, env_1.getEnvironmentVariable)("AZURE_OPENAI_API_KEY");
|
|
259
|
-
|
|
260
|
-
|
|
265
|
+
this.azureADTokenProvider = fields?.azureADTokenProvider ?? undefined;
|
|
266
|
+
if (!this.azureOpenAIApiKey && !this.apiKey && !this.azureADTokenProvider) {
|
|
267
|
+
throw new Error("OpenAI or Azure OpenAI API key or Token Provider not found");
|
|
261
268
|
}
|
|
262
269
|
this.azureOpenAIApiInstanceName =
|
|
263
270
|
fields?.azureOpenAIApiInstanceName ??
|
|
@@ -296,7 +303,7 @@ class OpenAI extends llms_1.BaseLLM {
|
|
|
296
303
|
if (this.streaming && this.bestOf && this.bestOf > 1) {
|
|
297
304
|
throw new Error("Cannot stream results when bestOf > 1");
|
|
298
305
|
}
|
|
299
|
-
if (this.azureOpenAIApiKey) {
|
|
306
|
+
if (this.azureOpenAIApiKey || this.azureADTokenProvider) {
|
|
300
307
|
if (!this.azureOpenAIApiInstanceName && !this.azureOpenAIBasePath) {
|
|
301
308
|
throw new Error("Azure OpenAI API instance name not found");
|
|
302
309
|
}
|
package/dist/llms.d.ts
CHANGED
|
@@ -67,12 +67,13 @@ export declare class OpenAI<CallOptions extends OpenAICallOptions = OpenAICallOp
|
|
|
67
67
|
apiKey?: string;
|
|
68
68
|
azureOpenAIApiVersion?: string;
|
|
69
69
|
azureOpenAIApiKey?: string;
|
|
70
|
+
azureADTokenProvider?: () => Promise<string>;
|
|
70
71
|
azureOpenAIApiInstanceName?: string;
|
|
71
72
|
azureOpenAIApiDeploymentName?: string;
|
|
72
73
|
azureOpenAIBasePath?: string;
|
|
73
74
|
organization?: string;
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
protected client: OpenAIClient;
|
|
76
|
+
protected clientConfig: ClientOptions;
|
|
76
77
|
constructor(fields?: Partial<OpenAIInput> & Partial<AzureOpenAIInput> & BaseLLMParams & {
|
|
77
78
|
configuration?: ClientOptions & LegacyOpenAIInput;
|
|
78
79
|
},
|
|
@@ -124,6 +125,6 @@ export declare class OpenAI<CallOptions extends OpenAICallOptions = OpenAICallOp
|
|
|
124
125
|
* @param options Optional configuration for the API call.
|
|
125
126
|
* @returns The response from the OpenAI API.
|
|
126
127
|
*/
|
|
127
|
-
|
|
128
|
+
protected _getClientOptions(options: OpenAICoreRequestOptions | undefined): OpenAICoreRequestOptions;
|
|
128
129
|
_llmType(): string;
|
|
129
130
|
}
|
package/dist/llms.js
CHANGED
|
@@ -208,6 +208,12 @@ export class OpenAI extends BaseLLM {
|
|
|
208
208
|
writable: true,
|
|
209
209
|
value: void 0
|
|
210
210
|
});
|
|
211
|
+
Object.defineProperty(this, "azureADTokenProvider", {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
configurable: true,
|
|
214
|
+
writable: true,
|
|
215
|
+
value: void 0
|
|
216
|
+
});
|
|
211
217
|
Object.defineProperty(this, "azureOpenAIApiInstanceName", {
|
|
212
218
|
enumerable: true,
|
|
213
219
|
configurable: true,
|
|
@@ -253,8 +259,9 @@ export class OpenAI extends BaseLLM {
|
|
|
253
259
|
this.azureOpenAIApiKey =
|
|
254
260
|
fields?.azureOpenAIApiKey ??
|
|
255
261
|
getEnvironmentVariable("AZURE_OPENAI_API_KEY");
|
|
256
|
-
|
|
257
|
-
|
|
262
|
+
this.azureADTokenProvider = fields?.azureADTokenProvider ?? undefined;
|
|
263
|
+
if (!this.azureOpenAIApiKey && !this.apiKey && !this.azureADTokenProvider) {
|
|
264
|
+
throw new Error("OpenAI or Azure OpenAI API key or Token Provider not found");
|
|
258
265
|
}
|
|
259
266
|
this.azureOpenAIApiInstanceName =
|
|
260
267
|
fields?.azureOpenAIApiInstanceName ??
|
|
@@ -293,7 +300,7 @@ export class OpenAI extends BaseLLM {
|
|
|
293
300
|
if (this.streaming && this.bestOf && this.bestOf > 1) {
|
|
294
301
|
throw new Error("Cannot stream results when bestOf > 1");
|
|
295
302
|
}
|
|
296
|
-
if (this.azureOpenAIApiKey) {
|
|
303
|
+
if (this.azureOpenAIApiKey || this.azureADTokenProvider) {
|
|
297
304
|
if (!this.azureOpenAIApiInstanceName && !this.azureOpenAIBasePath) {
|
|
298
305
|
throw new Error("Azure OpenAI API instance name not found");
|
|
299
306
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|