@gentrace/openai
Version:
Gentrace OpenAI v4 plugin for Node.JS
167 lines (164 loc) • 5.75 kB
JavaScript
import OpenAI from 'openai';
import { GentraceBetaChatCompletions, GentraceChatCompletions, OpenAIPipelineHandler, GentraceEmbeddings, GentraceModerations, GentraceCompletions } from '../openai.mjs';
import { Chat } from 'openai/resources/beta/chat/chat';
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
class AdvancedOpenAI extends OpenAIPipelineHandler {
constructor(options) {
super(Object.assign({}, options));
// @ts-ignore
this.completions = new AdvancedGentraceCompletions(Object.assign({
// @ts-ignore
client: this }, options));
// @ts-ignore
this.chat = new AdvancedGentraceChat(Object.assign({
// @ts-ignore
client: this }, options));
// @ts-ignore
this.beta = new AdvancedGentraceBeta(Object.assign({
// @ts-ignore
client: this }, options));
this.embeddings = new AdvancedGentraceEmbeddings(Object.assign({
// @ts-ignore
client: this }, options));
// @ts-ignore
this.moderations = new AdvancedGentraceModerations(Object.assign({
// @ts-ignore
client: this }, options));
}
}
class AdvancedGentraceEmbeddings extends GentraceEmbeddings {
constructor({ client, pipelineRun, gentraceConfig, }) {
super({
client,
gentraceConfig,
pipelineRun,
});
}
// @ts-ignore
create(body, options) {
const _super = Object.create(null, {
createInner: { get: () => super.createInner }
});
return __awaiter(this, void 0, void 0, function* () {
return _super.createInner.call(this, body, options);
});
}
}
class AdvancedGentraceModerations extends GentraceModerations {
constructor({ client, pipelineRun, gentraceConfig, }) {
super({
client,
gentraceConfig,
pipelineRun,
});
}
// @ts-ignore
create(body, options) {
const _super = Object.create(null, {
createInner: { get: () => super.createInner }
});
return __awaiter(this, void 0, void 0, function* () {
return _super.createInner.call(this, body, options);
});
}
}
class AdvancedGentraceCompletions extends GentraceCompletions {
constructor({ client, pipelineRun, gentraceConfig, }) {
super({
client,
pipelineRun,
gentraceConfig,
});
}
// @ts-ignore
create(body, requestOptions) {
const _super = Object.create(null, {
createInner: { get: () => super.createInner }
});
return __awaiter(this, void 0, void 0, function* () {
return _super.createInner.call(this, body, requestOptions);
});
}
}
class AdvancedGentraceBeta extends OpenAI.Beta {
constructor({ client, pipelineRun, gentraceConfig, }) {
super(client);
// @ts-ignore
this.chat = new AdvancedGentraceBetaChat({
// @ts-ignore
client,
pipelineRun,
gentraceConfig,
});
}
}
class AdvancedGentraceBetaChat extends Chat {
constructor({ client, pipelineRun, gentraceConfig, }) {
super(client);
// @ts-ignore
this.completions = new AdvancedGentraceBetaChatCompletions({
// @ts-ignore
client,
pipelineRun,
gentraceConfig,
});
}
}
class AdvancedGentraceBetaChatCompletions extends GentraceBetaChatCompletions {
constructor({ client, pipelineRun, gentraceConfig, }) {
super({
client,
pipelineRun,
gentraceConfig,
});
}
// @ts-ignore
parse(body, options) {
const _super = Object.create(null, {
parseInner: { get: () => super.parseInner }
});
return __awaiter(this, void 0, void 0, function* () {
return _super.parseInner.call(this, body, options);
});
}
}
class AdvancedGentraceChat extends OpenAI.Chat {
constructor({ client, pipelineRun, gentraceConfig, }) {
super(client);
// @ts-ignore
this.completions = new AdvancedGentraceChatCompletions({
// @ts-ignore
client,
pipelineRun,
gentraceConfig,
});
}
}
class AdvancedGentraceChatCompletions extends GentraceChatCompletions {
constructor({ client, pipelineRun, gentraceConfig, }) {
super({
client,
pipelineRun,
gentraceConfig,
});
}
// @ts-ignore
create(body, requestOptions) {
const _super = Object.create(null, {
createInner: { get: () => super.createInner }
});
return __awaiter(this, void 0, void 0, function* () {
return _super.createInner.call(this, body, requestOptions);
});
}
}
export { AdvancedGentraceBeta, AdvancedGentraceBetaChat, AdvancedGentraceChat, AdvancedGentraceCompletions, AdvancedOpenAI };
//# sourceMappingURL=advanced.mjs.map