UNPKG

portkey-ai

Version:
103 lines 6.03 kB
"use strict"; var __awaiter = (this && this.__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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MainFiles = void 0; const apiResource_1 = require("../apiResource.js"); const utils_1 = require("../utils.js"); const createHeaders_1 = require("./createHeaders.js"); class MainFiles extends apiResource_1.ApiResource { create(_body, params, opts) { return __awaiter(this, void 0, void 0, function* () { const body = _body; if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const OAIclient = (0, utils_1.initOpenAIClient)(this.client); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const result = yield OAIclient.files.create(body, opts).withResponse(); return (0, utils_1.finalResponse)(result); }); } list(_query, params, opts) { return __awaiter(this, void 0, void 0, function* () { const query = _query; if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const OAIclient = (0, utils_1.initOpenAIClient)(this.client); const result = yield OAIclient.files.list(query, opts).withResponse(); return (0, utils_1.finalResponse)(result); }); } retrieve(fileId, params, opts) { return __awaiter(this, void 0, void 0, function* () { if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const OAIclient = (0, utils_1.initOpenAIClient)(this.client); const result = yield OAIclient.files.retrieve(fileId, opts).withResponse(); return (0, utils_1.finalResponse)(result); }); } del(fileId, params, opts) { return __awaiter(this, void 0, void 0, function* () { if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const OAIclient = (0, utils_1.initOpenAIClient)(this.client); const result = yield OAIclient.files.del(fileId, opts).withResponse(); return (0, utils_1.finalResponse)(result); }); } content(fileId, params, opts) { return __awaiter(this, void 0, void 0, function* () { if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const OAIclient = (0, utils_1.initOpenAIClient)(this.client); const result = yield OAIclient.files.content(fileId, opts).withResponse(); return (0, utils_1.finalResponse)(result); }); } retrieveContent(fileId, params, opts) { return __awaiter(this, void 0, void 0, function* () { if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const OAIclient = (0, utils_1.initOpenAIClient)(this.client); const result = yield OAIclient.files.content(fileId, opts).withResponse(); return (0, utils_1.finalResponse)(result); }); } waitForProcessing(id, _body, params) { return __awaiter(this, void 0, void 0, function* () { const body = _body; if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const OAIclient = (0, utils_1.initOpenAIClient)(this.client); const result = yield OAIclient.files.waitForProcessing(id, Object.assign(Object.assign({}, (body.pollInterval !== undefined && { pollInterval: body.pollInterval, })), (body.maxWait !== undefined && { maxWait: body.maxWait }))); return result; }); } } exports.MainFiles = MainFiles; //# sourceMappingURL=files.js.map