UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

42 lines 2.07 kB
import { __awaiter } from "tslib"; export const rephraseSentenceWithAI = (sentence, config, api, organisationId) => __awaiter(void 0, void 0, void 0, function* () { const { generativeAI_rephraseOutputMode } = config; let newSentence = sentence; if (generativeAI_rephraseOutputMode === "userInputs" || generativeAI_rephraseOutputMode === "customInputs") { newSentence = yield api.rephraseSentenceWithAI(sentence, createRephraseSentenceWithAIOptions(config)); } newSentence !== sentence && api.logDebugMessage(`Rephrased sentence via AI<br>From: '${sentence}'<br>To: '${newSentence}'`, "Rephrased Sentence via AI"); return newSentence; }); export const rephraseMultipleSentencesWithAI = (sentences, config, api, organisationId) => __awaiter(void 0, void 0, void 0, function* () { const { generativeAI_rephraseOutputMode, generativeAI_amountOfLastUserInputs, generativeAI_customInputs, generativeAI_temperature } = config; if (generativeAI_rephraseOutputMode === "userInputs" || generativeAI_rephraseOutputMode === "customInputs") { sentences = yield api.rephraseMultipleSentencesWithAI(sentences, createRephraseSentenceWithAIOptions(config)); } return sentences; }); const createRephraseSentenceWithAIOptions = (params) => { const options = { promptType: params.promptType, questionType: params.questionType, temperature: params.generativeAI_temperature, question: params.question, answer: params.answer, }; switch (params.generativeAI_rephraseOutputMode) { case "none": break; case "userInputs": options.useLastUserInputs = true; options.amountOfUserInputs = params.generativeAI_amountOfLastUserInputs; return options; case "customInputs": options.useLastUserInputs = false; options.customInputs = params.generativeAI_customInputs; return options; default: break; } return {}; }; //# sourceMappingURL=rephraseSentenceWithAi.js.map