UNPKG

@questlabs/core

Version:
63 lines (62 loc) 3.18 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.GPT = void 0; const constants_1 = require("../../utils/constants"); const helperFunctions_1 = require("../../utils/helperFunctions"); class GPT { constructor(questSdk) { this.questSdk = questSdk; } createTextEmbeddingForEntity(_a, options_1) { return __awaiter(this, arguments, void 0, function* ({ embeddingText, entityId }, options) { try { const defaultEntityId = entityId || this.questSdk.getEntityId(); (0, helperFunctions_1.validateParams)({ entityId: defaultEntityId, embeddingText }); const url = `/ai/entities/${defaultEntityId}/embed-text`; const body = Object.assign({ embeddingText }, options === null || options === void 0 ? void 0 : options._body); return this.questSdk.makeRequest({ url, method: constants_1.HTTP_METHOD.POST, body, queryParams: options === null || options === void 0 ? void 0 : options._queryParams, headers: options === null || options === void 0 ? void 0 : options._headers, }); } catch (error) { this.questSdk.captureSentryException(error); throw error; } }); } makePromptRequestWithEmbedding(_a, options_1) { return __awaiter(this, arguments, void 0, function* ({ input, entityId }, options) { try { const defaultEntityId = entityId || this.questSdk.getEntityId(); (0, helperFunctions_1.validateParams)({ entityId: defaultEntityId, input }); const url = `/ai/entities/${defaultEntityId}/embed-query`; const body = Object.assign({ input }, options === null || options === void 0 ? void 0 : options._body); return this.questSdk.makeRequest({ url, method: constants_1.HTTP_METHOD.POST, body, queryParams: options === null || options === void 0 ? void 0 : options._queryParams, headers: options === null || options === void 0 ? void 0 : options._headers, }); } catch (error) { this.questSdk.captureSentryException(error); throw error; } }); } } exports.GPT = GPT;