UNPKG

@botonic/plugin-knowledge-bases

Version:

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

65 lines 2.3 kB
import { __awaiter } from "tslib"; /* eslint-disable @typescript-eslint/naming-convention */ import axios from 'axios'; const DEFAULT_TIMEOUT = 10000; export class HubtypeApiService { constructor(host, timeout) { this.host = host; this.timeout = timeout || DEFAULT_TIMEOUT; } inferenceV2(authToken, sources, instructions, messageId, memoryLength) { return __awaiter(this, void 0, void 0, function* () { return yield axios({ 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 __awaiter(this, void 0, void 0, function* () { return yield axios({ 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 __awaiter(this, void 0, void 0, function* () { return yield axios({ 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, }); }); } } //# sourceMappingURL=hubtype-knowledge-api-service.js.map