UNPKG

portkey-ai

Version:
164 lines 8.76 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Portkey = void 0; const API = __importStar(require("./apis/index.js")); const baseClient_1 = require("./baseClient.js"); const core_1 = require("./core.js"); const utils_1 = require("./utils.js"); class Portkey extends baseClient_1.ApiClient { constructor(_a) { var _b, _c; var { apiKey = (_b = (0, utils_1.readEnv)('PORTKEY_API_KEY')) !== null && _b !== void 0 ? _b : null, baseURL = (_c = (0, utils_1.readEnv)('PORTKEY_BASE_URL')) !== null && _c !== void 0 ? _c : null, config, virtualKey, provider, traceID, metadata, Authorization, cacheForceRefresh, debug, customHost, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, azureEndpointName, huggingfaceBaseUrl, forwardHeaders, cacheNamespace, requestTimeout, strictOpenAiCompliance, anthropicBeta, anthropicVersion, mistralFimCompletion, dangerouslyAllowBrowser, vertexStorageBucketName, providerFileName, providerModel, awsS3Bucket, awsS3ObjectKey, awsBedrockModel, fireworksAccountId, calculateAudioDuration } = _a, rest = __rest(_a, ["apiKey", "baseURL", "config", "virtualKey", "provider", "traceID", "metadata", "Authorization", "cacheForceRefresh", "debug", "customHost", "openaiProject", "openaiOrganization", "awsSecretAccessKey", "awsAccessKeyId", "awsSessionToken", "awsRegion", "vertexProjectId", "vertexRegion", "workersAiAccountId", "azureResourceName", "azureDeploymentId", "azureApiVersion", "azureEndpointName", "huggingfaceBaseUrl", "forwardHeaders", "cacheNamespace", "requestTimeout", "strictOpenAiCompliance", "anthropicBeta", "anthropicVersion", "mistralFimCompletion", "dangerouslyAllowBrowser", "vertexStorageBucketName", "providerFileName", "providerModel", "awsS3Bucket", "awsS3ObjectKey", "awsBedrockModel", "fireworksAccountId", "calculateAudioDuration"]); if ((0, core_1.isRunningInBrowser)() && !dangerouslyAllowBrowser) { throw new Error("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Portkey({ ..., dangerouslyAllowBrowser: true, ... });"); } super(Object.assign({ apiKey, baseURL, config, virtualKey, provider, traceID, metadata, Authorization, cacheForceRefresh, debug, customHost, cacheNamespace, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, azureEndpointName, huggingfaceBaseUrl, forwardHeaders, requestTimeout, strictOpenAiCompliance, anthropicBeta, anthropicVersion, mistralFimCompletion, dangerouslyAllowBrowser, vertexStorageBucketName, providerFileName, providerModel, awsS3Bucket, awsS3ObjectKey, awsBedrockModel, fireworksAccountId }, rest)); this.completions = new API.Completions(this); this.chat = new API.Chat(this); this.embeddings = new API.Embeddings(this); this.files = new API.MainFiles(this); this.images = new API.Images(this); this.models = new API.Models(this); this.generations = new API.Generations(this); this.prompts = new API.Prompt(this); this.labels = new API.Labels(this); this.collections = new API.Collections(this); this.feedback = new API.Feedback(this); this.batches = new API.Batches(this); this.fineTuning = new API.FineTuning(this); this.vectorStores = new API.VectorStores(this); this.moderations = new API.Moderations(this); this.audio = new API.Audio(this); this.uploads = new API.Uploads(this); this.responses = new API.Responses(this); this.admin = new API.Admin(this); this.virtualKeys = new API.VirtualKeys(this); this.apiKeys = new API.ApiKeys(this); this.configs = new API.Configs(this); this.logs = new API.Logs(this); this.beta = { assistants: new API.Assistants(this), threads: new API.Threads(this), chat: new API.BetaChat(this), realtime: new API.Realtime(this), }; this.post = (url, _body, params, opts) => { return new API.postMethod(this).create(url, _body, params, opts); }; this.baseURL = (0, utils_1.setBaseURL)(baseURL, apiKey); this.apiKey = (0, utils_1.setApiKey)(this.baseURL, apiKey); this.virtualKey = virtualKey || null; this.config = config || null; this.provider = provider; this.traceID = traceID; this.metadata = metadata; this.cacheForceRefresh = cacheForceRefresh; this.debug = debug; this.customHost = customHost; this.cacheNamespace = cacheNamespace; this.openaiProject = openaiProject; this.openaiOrganization = openaiOrganization; this.awsSecretAccessKey = awsSecretAccessKey; this.awsAccessKeyId = awsAccessKeyId; this.awsSessionToken = awsSessionToken; this.awsRegion = awsRegion; this.vertexProjectId = vertexProjectId; this.vertexRegion = vertexRegion; this.workersAiAccountId = workersAiAccountId; this.azureResourceName = azureResourceName; this.azureDeploymentId = azureDeploymentId; this.azureApiVersion = azureApiVersion; this.azureEndpointName = azureEndpointName; this.huggingfaceBaseUrl = huggingfaceBaseUrl; this.forwardHeaders = forwardHeaders; this.requestTimeout = requestTimeout; this.strictOpenAiCompliance = strictOpenAiCompliance; this.anthropicBeta = anthropicBeta; this.anthropicVersion = anthropicVersion; this.mistralFimCompletion = mistralFimCompletion; this.dangerouslyAllowBrowser = dangerouslyAllowBrowser !== null && dangerouslyAllowBrowser !== void 0 ? dangerouslyAllowBrowser : false; this.vertexStorageBucketName = vertexStorageBucketName; this.providerFileName = providerFileName; this.providerModel = providerModel; this.awsS3Bucket = awsS3Bucket; this.awsS3ObjectKey = awsS3ObjectKey; this.awsBedrockModel = awsBedrockModel; this.fireworksAccountId = fireworksAccountId; this.calculateAudioDuration = calculateAudioDuration !== null && calculateAudioDuration !== void 0 ? calculateAudioDuration : true; } } exports.Portkey = Portkey; //# sourceMappingURL=client.js.map