Skip to content

Commit

Permalink
chore: add built source code in dist
Browse files Browse the repository at this point in the history
  • Loading branch information
konsti committed Apr 28, 2023
1 parent be31012 commit 13c8052
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
24 changes: 21 additions & 3 deletions dist/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,15 @@ exports.OpenAIApiAxiosParamCreator = function (configuration) {
* @throws {RequiredError}
*/
createChatCompletion: (createChatCompletionRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
var _a, _b;
// verify required parameter 'createChatCompletionRequest' is not null or undefined
common_1.assertParamExists('createChatCompletion', 'createChatCompletionRequest', createChatCompletionRequest);
const localVarPath = `/chat/completions`;
let localVarPath = `/chat/completions`;
if (configuration.azure) {
const deploymentName = (_a = configuration.azure.deploymentName) !== null && _a !== void 0 ? _a : createChatCompletionRequest.model;
const apiVersion = (_b = configuration.azure.apiVersion) !== null && _b !== void 0 ? _b : '2023-03-15-preview';
localVarPath = `/openai/deployments/${deploymentName}/chat/completions?api-version=${apiVersion}`;
}
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
Expand Down Expand Up @@ -183,9 +189,15 @@ exports.OpenAIApiAxiosParamCreator = function (configuration) {
* @throws {RequiredError}
*/
createCompletion: (createCompletionRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
var _c, _d;
// verify required parameter 'createCompletionRequest' is not null or undefined
common_1.assertParamExists('createCompletion', 'createCompletionRequest', createCompletionRequest);
const localVarPath = `/completions`;
let localVarPath = `/completions`;
if (configuration.azure) {
const deploymentName = (_c = configuration.azure.deploymentName) !== null && _c !== void 0 ? _c : createCompletionRequest.model;
const apiVersion = (_d = configuration.azure.apiVersion) !== null && _d !== void 0 ? _d : '2023-03-15-preview';
localVarPath = `/openai/deployments/${deploymentName}/completions?api-version=${apiVersion}`;
}
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
Expand Down Expand Up @@ -243,9 +255,15 @@ exports.OpenAIApiAxiosParamCreator = function (configuration) {
* @throws {RequiredError}
*/
createEmbedding: (createEmbeddingRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
var _e, _f;
// verify required parameter 'createEmbeddingRequest' is not null or undefined
common_1.assertParamExists('createEmbedding', 'createEmbeddingRequest', createEmbeddingRequest);
const localVarPath = `/embeddings`;
let localVarPath = `/embeddings`;
if (configuration.azure) {
const deploymentName = (_e = configuration.azure.deploymentName) !== null && _e !== void 0 ? _e : createEmbeddingRequest.model;
const apiVersion = (_f = configuration.azure.apiVersion) !== null && _f !== void 0 ? _f : '2023-03-15-preview';
localVarPath = `/openai/deployments/${deploymentName}/embeddings?api-version=${apiVersion}`;
}
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
Expand Down
11 changes: 11 additions & 0 deletions dist/configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface AzureConfigurationParameters {
apiKey: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
endpoint: string;
deploymentName?: string;
apiVersion?: string;
}
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
organization?: string;
Expand All @@ -18,6 +24,7 @@ export interface ConfigurationParameters {
basePath?: string;
baseOptions?: any;
formDataCtor?: new () => any;
azure?: AzureConfigurationParameters;
}
export declare class Configuration {
/**
Expand Down Expand Up @@ -76,6 +83,10 @@ export declare class Configuration {
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
/**
* @memberof Configuration
*/
azure?: AzureConfigurationParameters;
constructor(param?: ConfigurationParameters);
/**
* Check if the given MIME is a JSON MIME.
Expand Down
12 changes: 11 additions & 1 deletion dist/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,26 @@ class Configuration {
this.basePath = param.basePath;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
this.azure = param.azure;
if (!this.baseOptions) {
this.baseOptions = {};
}
this.baseOptions.headers = Object.assign({ 'User-Agent': `OpenAI/NodeJS/${packageJson.version}`, 'Authorization': `Bearer ${this.apiKey}` }, this.baseOptions.headers);
this.baseOptions.headers = Object.assign({ 'User-Agent': `AzureOpenAI/NodeJS/${packageJson.version}`, 'Authorization': `Bearer ${this.apiKey}` }, this.baseOptions.headers);
if (this.organization) {
this.baseOptions.headers['OpenAI-Organization'] = this.organization;
}
if (!this.formDataCtor) {
this.formDataCtor = require("form-data");
}
if (this.azure) {
if (!this.azure.apiKey || !this.azure.endpoint) {
throw new Error("Azure Configuration requires apiKey and endpoint.");
}
this.apiKey = this.azure.apiKey;
this.baseOptions.headers['api-key'] = this.azure.apiKey;
this.baseOptions.headers['Authorization'] = '';
this.basePath = this.azure.endpoint;
}
}
/**
* Check if the given MIME is a JSON MIME.
Expand Down

0 comments on commit 13c8052

Please sign in to comment.