UNPKG

portkey-ai

Version:
38 lines 1.82 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _a, _b; Object.defineProperty(exports, "__esModule", { value: true }); const dotenv_1 = require("dotenv"); const src_1 = __importDefault(require("../src/index.js")); (0, dotenv_1.config)({ override: true }); // Initialize the Portkey client const portkey = new src_1.default({ apiKey: (_a = process.env["PORTKEY_API_KEY"]) !== null && _a !== void 0 ? _a : "", baseURL: "https://api.portkeydev.com/v1", provider: "openai", virtualKey: (_b = process.env["OPENAI_VIRTUAL_KEY"]) !== null && _b !== void 0 ? _b : "" }); // Generate a text completion function getTextCompletion() { var _a; return __awaiter(this, void 0, void 0, function* () { const completion = yield portkey.completions.create({ prompt: "Say this is a test", model: "gpt-3.5-turbo-instruct", }); console.log((_a = completion.choices[0]) === null || _a === void 0 ? void 0 : _a.text); }); } getTextCompletion(); //# sourceMappingURL=demo.js.map