@cognigy/rest-api-client
Version:
Cognigy REST-Client
46 lines • 2.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.rephraseMultipleSentencesWithAI = exports.rephraseSentenceWithAI = void 0;
const rephraseSentenceWithAI = async (sentence, config, api, organisationId) => {
const { generativeAI_rephraseOutputMode } = config;
let newSentence = sentence;
if (generativeAI_rephraseOutputMode === "userInputs" || generativeAI_rephraseOutputMode === "customInputs") {
newSentence = await 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;
};
exports.rephraseSentenceWithAI = rephraseSentenceWithAI;
const rephraseMultipleSentencesWithAI = async (sentences, config, api, organisationId) => {
const { generativeAI_rephraseOutputMode, generativeAI_amountOfLastUserInputs, generativeAI_customInputs, generativeAI_temperature } = config;
if (generativeAI_rephraseOutputMode === "userInputs" || generativeAI_rephraseOutputMode === "customInputs") {
sentences = await api.rephraseMultipleSentencesWithAI(sentences, createRephraseSentenceWithAIOptions(config));
}
return sentences;
};
exports.rephraseMultipleSentencesWithAI = rephraseMultipleSentencesWithAI;
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