UNPKG

@maximai/maxim-js

Version:

Maxim AI JS SDK. Visit https://getmaxim.ai for more info.

74 lines 2.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MaximPromptAPI = void 0; const maxim_1 = require("./maxim"); class MaximPromptAPI extends maxim_1.MaximAPI { constructor(baseUrl, apiKey) { super(baseUrl, apiKey); } async getPrompt(id) { return new Promise((resolve, reject) => { this.fetch(`/api/sdk/v4/prompts?promptId=${id}`) .then((response) => { if (response.error) { reject(response.error); } else { resolve(response.data); } }) .catch((error) => { reject(error); }); }); } async getPrompts() { return new Promise((resolve, reject) => { this.fetch(`/api/sdk/v4/prompts`) .then((response) => { if (response.error) { reject(response.error); } else { resolve(response.data); } }) .catch((error) => { reject(error); }); }); } async runPromptVersion(promptVersionId, input, options) { return new Promise((resolve, reject) => { const payload = { type: "maxim", promptVersionId, input, variables: (options === null || options === void 0 ? void 0 : options.variables) || {}, }; if (options === null || options === void 0 ? void 0 : options.imageUrls) { payload.imageUrls = options.imageUrls; } this.fetch("/api/sdk/v4/prompts/run", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(payload), }) .then((response) => { if (response.error) { reject(new Error(response.error.message)); } else { resolve(response.data); } }) .catch((error) => { reject(error); }); }); } } exports.MaximPromptAPI = MaximPromptAPI; //# sourceMappingURL=prompt.js.map