UNPKG

@botonic/plugin-knowledge-bases

Version:

Use a Hubtype to make the bot respond through a knowledge base.

69 lines 2.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HubtypeApiService = void 0; const tslib_1 = require("tslib"); /* eslint-disable @typescript-eslint/naming-convention */ const axios_1 = tslib_1.__importDefault(require("axios")); const DEFAULT_TIMEOUT = 10000; class HubtypeApiService { constructor(host, timeout) { this.host = host; this.timeout = timeout || DEFAULT_TIMEOUT; } inferenceV2(authToken, sources, instructions, messageId, memoryLength) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield (0, axios_1.default)({ method: 'POST', url: `${this.host}/external/v2/ai/knowledge_base/inference/`, headers: { Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/json', }, data: { sources, instructions, message: messageId, memory_length: memoryLength, }, timeout: this.timeout, }); }); } testInference(authToken, instructions, messages, sources) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield (0, axios_1.default)({ method: 'POST', url: `${this.host}/external/v1/ai/knowledge_base/test_inference/`, headers: { Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/json', }, data: { sources, instructions, messages, }, timeout: this.timeout, }); }); } inferenceV1(authToken, question, sources) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield (0, axios_1.default)({ method: 'POST', url: `${this.host}/external/v1/ai/knowledge_base/inference/`, headers: { Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/json', }, data: { question, sources, }, timeout: this.timeout, }); }); } } exports.HubtypeApiService = HubtypeApiService; //# sourceMappingURL=hubtype-knowledge-api-service.js.map