@gentrace/openai
Version:
Gentrace OpenAI v4 plugin for Node.JS
35 lines (32 loc) • 1.43 kB
JavaScript
import { isConfig, GentracePlugin } from '@gentrace/core';
import { AdvancedOpenAI } from './handlers/advanced.mjs';
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());
});
};
const initPlugin = (config) => __awaiter(void 0, void 0, void 0, function* () {
if (isConfig(config)) {
return new OpenAIPlugin(config);
}
return new OpenAIPlugin(config.getConfig());
});
class OpenAIPlugin extends GentracePlugin {
constructor(config) {
super();
this.config = config;
}
getConfig() {
return this.config;
}
advanced({ pipelineRun, gentraceConfig, }) {
return new AdvancedOpenAI(Object.assign({ pipelineRun,
gentraceConfig }, this.config));
}
}
export { OpenAIPlugin, initPlugin };
//# sourceMappingURL=plugin.mjs.map