feat: solution for 'Повторный экзамен: FAQ-бот — ChromaDB + один MCP-tool'

This commit is contained in:
2026-06-30 00:14:56 +03:00
parent f7c159346a
commit 1b9342d225
5 changed files with 225 additions and 68 deletions
+23
View File
@@ -0,0 +1,23 @@
const moderate = require('moderate-censor');
/**
* Moderates user input using moderate-censor.
* @param {string} text
* @returns {Promise<{allowed: boolean, reasons: string[]}>}
*/
async function moderateInput(text) {
try {
const result = await moderate.moderate(text);
if (result.isAllowed) {
return { allowed: true, reasons: [] };
} else {
return { allowed: false, reasons: result.reasons || [] };
}
} catch (err) {
console.error('Moderation error:', err);
// If moderation fails, default to allowing to avoid blocking legitimate queries
return { allowed: true, reasons: [] };
}
}
module.exports = { moderateInput };