@langchain/openai 0.0.0

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.
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenAIEmbeddings = void 0;
4
+ const openai_1 = require("openai");
5
+ const env_1 = require("@langchain/core/utils/env");
6
+ const embeddings_1 = require("@langchain/core/embeddings");
7
+ const chunk_js_1 = require("./utils/chunk.cjs");
8
+ const azure_js_1 = require("./utils/azure.cjs");
9
+ const openai_js_1 = require("./utils/openai.cjs");
10
+ /**
11
+ * Class for generating embeddings using the OpenAI API. Extends the
12
+ * Embeddings class and implements OpenAIEmbeddingsParams and
13
+ * AzureOpenAIInput.
14
+ * @example
15
+ * ```typescript
16
+ * // Embed a query using OpenAIEmbeddings to generate embeddings for a given text
17
+ * const model = new OpenAIEmbeddings();
18
+ * const res = await model.embedQuery(
19
+ * "What would be a good company name for a company that makes colorful socks?",
20
+ * );
21
+ * console.log({ res });
22
+ *
23
+ * ```
24
+ */
25
+ class OpenAIEmbeddings extends embeddings_1.Embeddings {
26
+ constructor(fields, configuration) {
27
+ const fieldsWithDefaults = { maxConcurrency: 2, ...fields };
28
+ super(fieldsWithDefaults);
29
+ Object.defineProperty(this, "modelName", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: "text-embedding-ada-002"
34
+ });
35
+ Object.defineProperty(this, "batchSize", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: 512
40
+ });
41
+ Object.defineProperty(this, "stripNewLines", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: true
46
+ });
47
+ Object.defineProperty(this, "timeout", {
48
+ enumerable: true,
49
+ configurable: true,
50
+ writable: true,
51
+ value: void 0
52
+ });
53
+ Object.defineProperty(this, "azureOpenAIApiVersion", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: void 0
58
+ });
59
+ Object.defineProperty(this, "azureOpenAIApiKey", {
60
+ enumerable: true,
61
+ configurable: true,
62
+ writable: true,
63
+ value: void 0
64
+ });
65
+ Object.defineProperty(this, "azureOpenAIApiInstanceName", {
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true,
69
+ value: void 0
70
+ });
71
+ Object.defineProperty(this, "azureOpenAIApiDeploymentName", {
72
+ enumerable: true,
73
+ configurable: true,
74
+ writable: true,
75
+ value: void 0
76
+ });
77
+ Object.defineProperty(this, "azureOpenAIBasePath", {
78
+ enumerable: true,
79
+ configurable: true,
80
+ writable: true,
81
+ value: void 0
82
+ });
83
+ Object.defineProperty(this, "organization", {
84
+ enumerable: true,
85
+ configurable: true,
86
+ writable: true,
87
+ value: void 0
88
+ });
89
+ Object.defineProperty(this, "client", {
90
+ enumerable: true,
91
+ configurable: true,
92
+ writable: true,
93
+ value: void 0
94
+ });
95
+ Object.defineProperty(this, "clientConfig", {
96
+ enumerable: true,
97
+ configurable: true,
98
+ writable: true,
99
+ value: void 0
100
+ });
101
+ let apiKey = fieldsWithDefaults?.openAIApiKey ??
102
+ (0, env_1.getEnvironmentVariable)("OPENAI_API_KEY");
103
+ const azureApiKey = fieldsWithDefaults?.azureOpenAIApiKey ??
104
+ (0, env_1.getEnvironmentVariable)("AZURE_OPENAI_API_KEY");
105
+ if (!azureApiKey && !apiKey) {
106
+ throw new Error("OpenAI or Azure OpenAI API key not found");
107
+ }
108
+ const azureApiInstanceName = fieldsWithDefaults?.azureOpenAIApiInstanceName ??
109
+ (0, env_1.getEnvironmentVariable)("AZURE_OPENAI_API_INSTANCE_NAME");
110
+ const azureApiDeploymentName = (fieldsWithDefaults?.azureOpenAIApiEmbeddingsDeploymentName ||
111
+ fieldsWithDefaults?.azureOpenAIApiDeploymentName) ??
112
+ ((0, env_1.getEnvironmentVariable)("AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME") ||
113
+ (0, env_1.getEnvironmentVariable)("AZURE_OPENAI_API_DEPLOYMENT_NAME"));
114
+ const azureApiVersion = fieldsWithDefaults?.azureOpenAIApiVersion ??
115
+ (0, env_1.getEnvironmentVariable)("AZURE_OPENAI_API_VERSION");
116
+ this.azureOpenAIBasePath =
117
+ fieldsWithDefaults?.azureOpenAIBasePath ??
118
+ (0, env_1.getEnvironmentVariable)("AZURE_OPENAI_BASE_PATH");
119
+ this.organization =
120
+ fieldsWithDefaults?.configuration?.organization ??
121
+ (0, env_1.getEnvironmentVariable)("OPENAI_ORGANIZATION");
122
+ this.modelName = fieldsWithDefaults?.modelName ?? this.modelName;
123
+ this.batchSize =
124
+ fieldsWithDefaults?.batchSize ?? (azureApiKey ? 1 : this.batchSize);
125
+ this.stripNewLines =
126
+ fieldsWithDefaults?.stripNewLines ?? this.stripNewLines;
127
+ this.timeout = fieldsWithDefaults?.timeout;
128
+ this.azureOpenAIApiVersion = azureApiVersion;
129
+ this.azureOpenAIApiKey = azureApiKey;
130
+ this.azureOpenAIApiInstanceName = azureApiInstanceName;
131
+ this.azureOpenAIApiDeploymentName = azureApiDeploymentName;
132
+ if (this.azureOpenAIApiKey) {
133
+ if (!this.azureOpenAIApiInstanceName && !this.azureOpenAIBasePath) {
134
+ throw new Error("Azure OpenAI API instance name not found");
135
+ }
136
+ if (!this.azureOpenAIApiDeploymentName) {
137
+ throw new Error("Azure OpenAI API deployment name not found");
138
+ }
139
+ if (!this.azureOpenAIApiVersion) {
140
+ throw new Error("Azure OpenAI API version not found");
141
+ }
142
+ apiKey = apiKey ?? "";
143
+ }
144
+ this.clientConfig = {
145
+ apiKey,
146
+ organization: this.organization,
147
+ baseURL: configuration?.basePath,
148
+ dangerouslyAllowBrowser: true,
149
+ defaultHeaders: configuration?.baseOptions?.headers,
150
+ defaultQuery: configuration?.baseOptions?.params,
151
+ ...configuration,
152
+ ...fields?.configuration,
153
+ };
154
+ }
155
+ /**
156
+ * Method to generate embeddings for an array of documents. Splits the
157
+ * documents into batches and makes requests to the OpenAI API to generate
158
+ * embeddings.
159
+ * @param texts Array of documents to generate embeddings for.
160
+ * @returns Promise that resolves to a 2D array of embeddings for each document.
161
+ */
162
+ async embedDocuments(texts) {
163
+ const batches = (0, chunk_js_1.chunkArray)(this.stripNewLines ? texts.map((t) => t.replace(/\n/g, " ")) : texts, this.batchSize);
164
+ const batchRequests = batches.map((batch) => this.embeddingWithRetry({
165
+ model: this.modelName,
166
+ input: batch,
167
+ }));
168
+ const batchResponses = await Promise.all(batchRequests);
169
+ const embeddings = [];
170
+ for (let i = 0; i < batchResponses.length; i += 1) {
171
+ const batch = batches[i];
172
+ const { data: batchResponse } = batchResponses[i];
173
+ for (let j = 0; j < batch.length; j += 1) {
174
+ embeddings.push(batchResponse[j].embedding);
175
+ }
176
+ }
177
+ return embeddings;
178
+ }
179
+ /**
180
+ * Method to generate an embedding for a single document. Calls the
181
+ * embeddingWithRetry method with the document as the input.
182
+ * @param text Document to generate an embedding for.
183
+ * @returns Promise that resolves to an embedding for the document.
184
+ */
185
+ async embedQuery(text) {
186
+ const { data } = await this.embeddingWithRetry({
187
+ model: this.modelName,
188
+ input: this.stripNewLines ? text.replace(/\n/g, " ") : text,
189
+ });
190
+ return data[0].embedding;
191
+ }
192
+ /**
193
+ * Private method to make a request to the OpenAI API to generate
194
+ * embeddings. Handles the retry logic and returns the response from the
195
+ * API.
196
+ * @param request Request to send to the OpenAI API.
197
+ * @returns Promise that resolves to the response from the API.
198
+ */
199
+ async embeddingWithRetry(request) {
200
+ if (!this.client) {
201
+ const openAIEndpointConfig = {
202
+ azureOpenAIApiDeploymentName: this.azureOpenAIApiDeploymentName,
203
+ azureOpenAIApiInstanceName: this.azureOpenAIApiInstanceName,
204
+ azureOpenAIApiKey: this.azureOpenAIApiKey,
205
+ azureOpenAIBasePath: this.azureOpenAIBasePath,
206
+ baseURL: this.clientConfig.baseURL,
207
+ };
208
+ const endpoint = (0, azure_js_1.getEndpoint)(openAIEndpointConfig);
209
+ const params = {
210
+ ...this.clientConfig,
211
+ baseURL: endpoint,
212
+ timeout: this.timeout,
213
+ maxRetries: 0,
214
+ };
215
+ if (!params.baseURL) {
216
+ delete params.baseURL;
217
+ }
218
+ this.client = new openai_1.OpenAI(params);
219
+ }
220
+ const requestOptions = {};
221
+ if (this.azureOpenAIApiKey) {
222
+ requestOptions.headers = {
223
+ "api-key": this.azureOpenAIApiKey,
224
+ ...requestOptions.headers,
225
+ };
226
+ requestOptions.query = {
227
+ "api-version": this.azureOpenAIApiVersion,
228
+ ...requestOptions.query,
229
+ };
230
+ }
231
+ return this.caller.call(async () => {
232
+ try {
233
+ const res = await this.client.embeddings.create(request, requestOptions);
234
+ return res;
235
+ }
236
+ catch (e) {
237
+ const error = (0, openai_js_1.wrapOpenAIClientError)(e);
238
+ throw error;
239
+ }
240
+ });
241
+ }
242
+ }
243
+ exports.OpenAIEmbeddings = OpenAIEmbeddings;
@@ -0,0 +1,82 @@
1
+ import { type ClientOptions } from "openai";
2
+ import { Embeddings, type EmbeddingsParams } from "@langchain/core/embeddings";
3
+ import { AzureOpenAIInput, LegacyOpenAIInput } from "./types.js";
4
+ /**
5
+ * Interface for OpenAIEmbeddings parameters. Extends EmbeddingsParams and
6
+ * defines additional parameters specific to the OpenAIEmbeddings class.
7
+ */
8
+ export interface OpenAIEmbeddingsParams extends EmbeddingsParams {
9
+ /** Model name to use */
10
+ modelName: string;
11
+ /**
12
+ * Timeout to use when making requests to OpenAI.
13
+ */
14
+ timeout?: number;
15
+ /**
16
+ * The maximum number of documents to embed in a single request. This is
17
+ * limited by the OpenAI API to a maximum of 2048.
18
+ */
19
+ batchSize?: number;
20
+ /**
21
+ * Whether to strip new lines from the input text. This is recommended by
22
+ * OpenAI, but may not be suitable for all use cases.
23
+ */
24
+ stripNewLines?: boolean;
25
+ }
26
+ /**
27
+ * Class for generating embeddings using the OpenAI API. Extends the
28
+ * Embeddings class and implements OpenAIEmbeddingsParams and
29
+ * AzureOpenAIInput.
30
+ * @example
31
+ * ```typescript
32
+ * // Embed a query using OpenAIEmbeddings to generate embeddings for a given text
33
+ * const model = new OpenAIEmbeddings();
34
+ * const res = await model.embedQuery(
35
+ * "What would be a good company name for a company that makes colorful socks?",
36
+ * );
37
+ * console.log({ res });
38
+ *
39
+ * ```
40
+ */
41
+ export declare class OpenAIEmbeddings extends Embeddings implements OpenAIEmbeddingsParams, AzureOpenAIInput {
42
+ modelName: string;
43
+ batchSize: number;
44
+ stripNewLines: boolean;
45
+ timeout?: number;
46
+ azureOpenAIApiVersion?: string;
47
+ azureOpenAIApiKey?: string;
48
+ azureOpenAIApiInstanceName?: string;
49
+ azureOpenAIApiDeploymentName?: string;
50
+ azureOpenAIBasePath?: string;
51
+ organization?: string;
52
+ private client;
53
+ private clientConfig;
54
+ constructor(fields?: Partial<OpenAIEmbeddingsParams> & Partial<AzureOpenAIInput> & {
55
+ verbose?: boolean;
56
+ openAIApiKey?: string;
57
+ configuration?: ClientOptions;
58
+ }, configuration?: ClientOptions & LegacyOpenAIInput);
59
+ /**
60
+ * Method to generate embeddings for an array of documents. Splits the
61
+ * documents into batches and makes requests to the OpenAI API to generate
62
+ * embeddings.
63
+ * @param texts Array of documents to generate embeddings for.
64
+ * @returns Promise that resolves to a 2D array of embeddings for each document.
65
+ */
66
+ embedDocuments(texts: string[]): Promise<number[][]>;
67
+ /**
68
+ * Method to generate an embedding for a single document. Calls the
69
+ * embeddingWithRetry method with the document as the input.
70
+ * @param text Document to generate an embedding for.
71
+ * @returns Promise that resolves to an embedding for the document.
72
+ */
73
+ embedQuery(text: string): Promise<number[]>;
74
+ /**
75
+ * Private method to make a request to the OpenAI API to generate
76
+ * embeddings. Handles the retry logic and returns the response from the
77
+ * API.
78
+ * @param request Request to send to the OpenAI API.
79
+ * @returns Promise that resolves to the response from the API.
80
+ */
81
+ private embeddingWithRetry;
82
+ }
@@ -0,0 +1,239 @@
1
+ import { OpenAI as OpenAIClient } from "openai";
2
+ import { getEnvironmentVariable } from "@langchain/core/utils/env";
3
+ import { Embeddings } from "@langchain/core/embeddings";
4
+ import { chunkArray } from "./utils/chunk.js";
5
+ import { getEndpoint } from "./utils/azure.js";
6
+ import { wrapOpenAIClientError } from "./utils/openai.js";
7
+ /**
8
+ * Class for generating embeddings using the OpenAI API. Extends the
9
+ * Embeddings class and implements OpenAIEmbeddingsParams and
10
+ * AzureOpenAIInput.
11
+ * @example
12
+ * ```typescript
13
+ * // Embed a query using OpenAIEmbeddings to generate embeddings for a given text
14
+ * const model = new OpenAIEmbeddings();
15
+ * const res = await model.embedQuery(
16
+ * "What would be a good company name for a company that makes colorful socks?",
17
+ * );
18
+ * console.log({ res });
19
+ *
20
+ * ```
21
+ */
22
+ export class OpenAIEmbeddings extends Embeddings {
23
+ constructor(fields, configuration) {
24
+ const fieldsWithDefaults = { maxConcurrency: 2, ...fields };
25
+ super(fieldsWithDefaults);
26
+ Object.defineProperty(this, "modelName", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: "text-embedding-ada-002"
31
+ });
32
+ Object.defineProperty(this, "batchSize", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: 512
37
+ });
38
+ Object.defineProperty(this, "stripNewLines", {
39
+ enumerable: true,
40
+ configurable: true,
41
+ writable: true,
42
+ value: true
43
+ });
44
+ Object.defineProperty(this, "timeout", {
45
+ enumerable: true,
46
+ configurable: true,
47
+ writable: true,
48
+ value: void 0
49
+ });
50
+ Object.defineProperty(this, "azureOpenAIApiVersion", {
51
+ enumerable: true,
52
+ configurable: true,
53
+ writable: true,
54
+ value: void 0
55
+ });
56
+ Object.defineProperty(this, "azureOpenAIApiKey", {
57
+ enumerable: true,
58
+ configurable: true,
59
+ writable: true,
60
+ value: void 0
61
+ });
62
+ Object.defineProperty(this, "azureOpenAIApiInstanceName", {
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true,
66
+ value: void 0
67
+ });
68
+ Object.defineProperty(this, "azureOpenAIApiDeploymentName", {
69
+ enumerable: true,
70
+ configurable: true,
71
+ writable: true,
72
+ value: void 0
73
+ });
74
+ Object.defineProperty(this, "azureOpenAIBasePath", {
75
+ enumerable: true,
76
+ configurable: true,
77
+ writable: true,
78
+ value: void 0
79
+ });
80
+ Object.defineProperty(this, "organization", {
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true,
84
+ value: void 0
85
+ });
86
+ Object.defineProperty(this, "client", {
87
+ enumerable: true,
88
+ configurable: true,
89
+ writable: true,
90
+ value: void 0
91
+ });
92
+ Object.defineProperty(this, "clientConfig", {
93
+ enumerable: true,
94
+ configurable: true,
95
+ writable: true,
96
+ value: void 0
97
+ });
98
+ let apiKey = fieldsWithDefaults?.openAIApiKey ??
99
+ getEnvironmentVariable("OPENAI_API_KEY");
100
+ const azureApiKey = fieldsWithDefaults?.azureOpenAIApiKey ??
101
+ getEnvironmentVariable("AZURE_OPENAI_API_KEY");
102
+ if (!azureApiKey && !apiKey) {
103
+ throw new Error("OpenAI or Azure OpenAI API key not found");
104
+ }
105
+ const azureApiInstanceName = fieldsWithDefaults?.azureOpenAIApiInstanceName ??
106
+ getEnvironmentVariable("AZURE_OPENAI_API_INSTANCE_NAME");
107
+ const azureApiDeploymentName = (fieldsWithDefaults?.azureOpenAIApiEmbeddingsDeploymentName ||
108
+ fieldsWithDefaults?.azureOpenAIApiDeploymentName) ??
109
+ (getEnvironmentVariable("AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME") ||
110
+ getEnvironmentVariable("AZURE_OPENAI_API_DEPLOYMENT_NAME"));
111
+ const azureApiVersion = fieldsWithDefaults?.azureOpenAIApiVersion ??
112
+ getEnvironmentVariable("AZURE_OPENAI_API_VERSION");
113
+ this.azureOpenAIBasePath =
114
+ fieldsWithDefaults?.azureOpenAIBasePath ??
115
+ getEnvironmentVariable("AZURE_OPENAI_BASE_PATH");
116
+ this.organization =
117
+ fieldsWithDefaults?.configuration?.organization ??
118
+ getEnvironmentVariable("OPENAI_ORGANIZATION");
119
+ this.modelName = fieldsWithDefaults?.modelName ?? this.modelName;
120
+ this.batchSize =
121
+ fieldsWithDefaults?.batchSize ?? (azureApiKey ? 1 : this.batchSize);
122
+ this.stripNewLines =
123
+ fieldsWithDefaults?.stripNewLines ?? this.stripNewLines;
124
+ this.timeout = fieldsWithDefaults?.timeout;
125
+ this.azureOpenAIApiVersion = azureApiVersion;
126
+ this.azureOpenAIApiKey = azureApiKey;
127
+ this.azureOpenAIApiInstanceName = azureApiInstanceName;
128
+ this.azureOpenAIApiDeploymentName = azureApiDeploymentName;
129
+ if (this.azureOpenAIApiKey) {
130
+ if (!this.azureOpenAIApiInstanceName && !this.azureOpenAIBasePath) {
131
+ throw new Error("Azure OpenAI API instance name not found");
132
+ }
133
+ if (!this.azureOpenAIApiDeploymentName) {
134
+ throw new Error("Azure OpenAI API deployment name not found");
135
+ }
136
+ if (!this.azureOpenAIApiVersion) {
137
+ throw new Error("Azure OpenAI API version not found");
138
+ }
139
+ apiKey = apiKey ?? "";
140
+ }
141
+ this.clientConfig = {
142
+ apiKey,
143
+ organization: this.organization,
144
+ baseURL: configuration?.basePath,
145
+ dangerouslyAllowBrowser: true,
146
+ defaultHeaders: configuration?.baseOptions?.headers,
147
+ defaultQuery: configuration?.baseOptions?.params,
148
+ ...configuration,
149
+ ...fields?.configuration,
150
+ };
151
+ }
152
+ /**
153
+ * Method to generate embeddings for an array of documents. Splits the
154
+ * documents into batches and makes requests to the OpenAI API to generate
155
+ * embeddings.
156
+ * @param texts Array of documents to generate embeddings for.
157
+ * @returns Promise that resolves to a 2D array of embeddings for each document.
158
+ */
159
+ async embedDocuments(texts) {
160
+ const batches = chunkArray(this.stripNewLines ? texts.map((t) => t.replace(/\n/g, " ")) : texts, this.batchSize);
161
+ const batchRequests = batches.map((batch) => this.embeddingWithRetry({
162
+ model: this.modelName,
163
+ input: batch,
164
+ }));
165
+ const batchResponses = await Promise.all(batchRequests);
166
+ const embeddings = [];
167
+ for (let i = 0; i < batchResponses.length; i += 1) {
168
+ const batch = batches[i];
169
+ const { data: batchResponse } = batchResponses[i];
170
+ for (let j = 0; j < batch.length; j += 1) {
171
+ embeddings.push(batchResponse[j].embedding);
172
+ }
173
+ }
174
+ return embeddings;
175
+ }
176
+ /**
177
+ * Method to generate an embedding for a single document. Calls the
178
+ * embeddingWithRetry method with the document as the input.
179
+ * @param text Document to generate an embedding for.
180
+ * @returns Promise that resolves to an embedding for the document.
181
+ */
182
+ async embedQuery(text) {
183
+ const { data } = await this.embeddingWithRetry({
184
+ model: this.modelName,
185
+ input: this.stripNewLines ? text.replace(/\n/g, " ") : text,
186
+ });
187
+ return data[0].embedding;
188
+ }
189
+ /**
190
+ * Private method to make a request to the OpenAI API to generate
191
+ * embeddings. Handles the retry logic and returns the response from the
192
+ * API.
193
+ * @param request Request to send to the OpenAI API.
194
+ * @returns Promise that resolves to the response from the API.
195
+ */
196
+ async embeddingWithRetry(request) {
197
+ if (!this.client) {
198
+ const openAIEndpointConfig = {
199
+ azureOpenAIApiDeploymentName: this.azureOpenAIApiDeploymentName,
200
+ azureOpenAIApiInstanceName: this.azureOpenAIApiInstanceName,
201
+ azureOpenAIApiKey: this.azureOpenAIApiKey,
202
+ azureOpenAIBasePath: this.azureOpenAIBasePath,
203
+ baseURL: this.clientConfig.baseURL,
204
+ };
205
+ const endpoint = getEndpoint(openAIEndpointConfig);
206
+ const params = {
207
+ ...this.clientConfig,
208
+ baseURL: endpoint,
209
+ timeout: this.timeout,
210
+ maxRetries: 0,
211
+ };
212
+ if (!params.baseURL) {
213
+ delete params.baseURL;
214
+ }
215
+ this.client = new OpenAIClient(params);
216
+ }
217
+ const requestOptions = {};
218
+ if (this.azureOpenAIApiKey) {
219
+ requestOptions.headers = {
220
+ "api-key": this.azureOpenAIApiKey,
221
+ ...requestOptions.headers,
222
+ };
223
+ requestOptions.query = {
224
+ "api-version": this.azureOpenAIApiVersion,
225
+ ...requestOptions.query,
226
+ };
227
+ }
228
+ return this.caller.call(async () => {
229
+ try {
230
+ const res = await this.client.embeddings.create(request, requestOptions);
231
+ return res;
232
+ }
233
+ catch (e) {
234
+ const error = wrapOpenAIClientError(e);
235
+ throw error;
236
+ }
237
+ });
238
+ }
239
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.toFile = exports.OpenAIClient = void 0;
18
+ var openai_1 = require("openai");
19
+ Object.defineProperty(exports, "OpenAIClient", { enumerable: true, get: function () { return openai_1.OpenAI; } });
20
+ Object.defineProperty(exports, "toFile", { enumerable: true, get: function () { return openai_1.toFile; } });
21
+ __exportStar(require("./chat_models.cjs"), exports);
22
+ __exportStar(require("./llms.cjs"), exports);
23
+ __exportStar(require("./embeddings.cjs"), exports);
24
+ __exportStar(require("./types.cjs"), exports);
25
+ __exportStar(require("./utils/openai.cjs"), exports);
26
+ __exportStar(require("./utils/azure.cjs"), exports);
@@ -0,0 +1,7 @@
1
+ export { OpenAI as OpenAIClient, type ClientOptions, toFile } from "openai";
2
+ export * from "./chat_models.js";
3
+ export * from "./llms.js";
4
+ export * from "./embeddings.js";
5
+ export * from "./types.js";
6
+ export * from "./utils/openai.js";
7
+ export * from "./utils/azure.js";
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { OpenAI as OpenAIClient, toFile } from "openai";
2
+ export * from "./chat_models.js";
3
+ export * from "./llms.js";
4
+ export * from "./embeddings.js";
5
+ export * from "./types.js";
6
+ export * from "./utils/openai.js";
7
+ export * from "./utils/azure.js";