Remove Ki-Moderator add more backlist

This commit is contained in:
2025-09-15 18:59:25 +02:00
parent 6d5dc9eb7a
commit 7cce818932
5 changed files with 53 additions and 523 deletions

View File

@@ -106,12 +106,6 @@
<button class="btn" onclick="showBlacklistManagement()">Blacklist verwalten</button>
</div>
<!-- KI-Moderator -->
<div class="card">
<h3><span class="icon">🧠</span> KI-Moderator</h3>
<p>Intelligente Namensprüfung mit Ollama LLM</p>
<button class="btn" onclick="showLLMManagement()">KI-Moderator testen</button>
</div>
<!-- Läufe-Verwaltung -->
<div class="card">
@@ -211,6 +205,13 @@
<option value="titles">Titel/Berufsbezeichnung</option>
<option value="brands">Markenname</option>
<option value="inappropriate">Unpassend</option>
<option value="racial">Rassistisch/ethnisch</option>
<option value="religious">Religiös beleidigend</option>
<option value="disability">Behinderungsbezogen</option>
<option value="leetspeak">Verschleiert</option>
<option value="cyberbullying">Cyberbullying</option>
<option value="drugs">Drogenbezogen</option>
<option value="violence">Gewalt/Bedrohung</option>
</select>
<button class="btn btn-success" onclick="addToBlacklist()">Hinzufügen</button>
</div>
@@ -237,49 +238,6 @@
</div>
</footer>
<!-- LLM-Moderator Modal -->
<div id="llmModal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeLLMModal()">&times;</span>
<h2>🧠 KI-Moderator</h2>
<!-- LLM-Status -->
<div id="llmStatus" class="llm-status-section">
<h3>Status</h3>
<div id="llmStatusContent">Lade...</div>
</div>
<!-- Name testen -->
<div class="llm-test-section">
<h3>Name testen</h3>
<div class="form-group">
<label for="llmFirstname">Vorname:</label>
<input type="text" id="llmFirstname" placeholder="Vorname eingeben">
</div>
<div class="form-group">
<label for="llmLastname">Nachname:</label>
<input type="text" id="llmLastname" placeholder="Nachname eingeben">
</div>
<div class="form-group">
<label for="llmContext">Kontext (optional):</label>
<input type="text" id="llmContext" placeholder="Zusätzlicher Kontext">
</div>
<button onclick="testNameWithLLM()" class="btn btn-primary">Mit KI prüfen</button>
</div>
<!-- Ergebnis -->
<div id="llmResult" class="llm-result-section" style="display: none;">
<h3>Ergebnis</h3>
<div id="llmResultContent"></div>
</div>
<!-- Vergleich mit Blacklist -->
<div id="llmComparison" class="llm-comparison-section" style="display: none;">
<h3>Vergleich mit Blacklist</h3>
<div id="llmComparisonContent"></div>
</div>
</div>
</div>
<!-- Application JavaScript -->
<script src="/js/cookie-consent.js"></script>

View File

@@ -893,7 +893,14 @@ function getCategoryIcon(category) {
offensive: '⚠️',
titles: '👑',
brands: '🏷️',
inappropriate: '🚫'
inappropriate: '🚫',
racial: '🌍',
religious: '⛪',
disability: '♿',
leetspeak: '🔤',
cyberbullying: '💻',
drugs: '💊',
violence: '⚔️'
};
return icons[category] || '📝';
}
@@ -904,7 +911,14 @@ function getCategoryDisplayName(category) {
offensive: 'Beleidigend/anstößig',
titles: 'Titel/Berufsbezeichnung',
brands: 'Markenname',
inappropriate: 'Unpassend'
inappropriate: 'Unpassend',
racial: 'Rassistisch/ethnisch',
religious: 'Religiös beleidigend',
disability: 'Behinderungsbezogen',
leetspeak: 'Verschleiert',
cyberbullying: 'Cyberbullying',
drugs: 'Drogenbezogen',
violence: 'Gewalt/Bedrohung'
};
return names[category] || category;
}
@@ -1103,196 +1117,7 @@ function displayBlacklistStats(stats) {
statsDiv.innerHTML = html;
}
// LLM-Management
function showLLMManagement() {
document.getElementById('llmModal').style.display = 'block';
loadLLMStatus();
}
function closeLLMModal() {
document.getElementById('llmModal').style.display = 'none';
}
// LLM-Status laden
async function loadLLMStatus() {
try {
const response = await fetch('/api/v1/admin/llm/status', {
headers: {
'Authorization': `Bearer ${localStorage.getItem('adminToken')}`
}
});
const result = await response.json();
const statusContent = document.getElementById('llmStatusContent');
if (result.success) {
const status = result.data;
if (status.connected) {
statusContent.innerHTML = `
<div style="background: #e8f5e8; color: #2e7d32; padding: 0.5rem; border-radius: 3px;">
<strong>✅ KI-Moderator verbunden</strong><br>
Modell: ${status.model}<br>
URL: ${status.baseUrl}
</div>
`;
} else {
statusContent.innerHTML = `
<div style="background: #ffebee; color: #c62828; padding: 0.5rem; border-radius: 3px;">
<strong>❌ KI-Moderator nicht verfügbar</strong><br>
Modell: ${status.model}<br>
URL: ${status.baseUrl}<br>
Fehler: ${status.error}
</div>
`;
}
} else {
statusContent.innerHTML = `
<div style="background: #ffebee; color: #c62828; padding: 0.5rem; border-radius: 3px;">
<strong>❌ Fehler beim Laden des Status</strong><br>
${result.message}
</div>
`;
}
} catch (error) {
console.error('Error loading LLM status:', error);
document.getElementById('llmStatusContent').innerHTML = `
<div style="background: #ffebee; color: #c62828; padding: 0.5rem; border-radius: 3px;">
<strong>❌ Fehler beim Laden des Status</strong><br>
${error.message}
</div>
`;
}
}
// Name mit LLM testen
async function testNameWithLLM() {
const firstname = document.getElementById('llmFirstname').value.trim();
const lastname = document.getElementById('llmLastname').value.trim();
const context = document.getElementById('llmContext').value.trim();
if (!firstname || !lastname) {
showLLMMessage('Bitte gib Vorname und Nachname ein', 'error');
return;
}
try {
// LLM-Test
const llmResponse = await fetch('/api/v1/admin/llm/test', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${localStorage.getItem('adminToken')}`
},
body: JSON.stringify({ firstname, lastname, context })
});
const llmResult = await llmResponse.json();
// Blacklist-Test zum Vergleich
const blacklistResponse = await fetch('/api/v1/admin/blacklist/test', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${localStorage.getItem('adminToken')}`
},
body: JSON.stringify({ firstname, lastname })
});
const blacklistResult = await blacklistResponse.json();
// Ergebnisse anzeigen
displayLLMResults(llmResult, blacklistResult);
} catch (error) {
console.error('Error testing name with LLM:', error);
showLLMMessage('Fehler beim Testen: ' + error.message, 'error');
}
}
// LLM-Ergebnisse anzeigen
function displayLLMResults(llmResult, blacklistResult) {
const resultDiv = document.getElementById('llmResult');
const resultContent = document.getElementById('llmResultContent');
const comparisonDiv = document.getElementById('llmComparison');
const comparisonContent = document.getElementById('llmComparisonContent');
if (llmResult.success) {
const llm = llmResult.data;
let llmStatus = '';
if (llm.isBlocked) {
llmStatus = `
<div style="background: #ffebee; color: #c62828; padding: 0.5rem; border-radius: 3px;">
<strong>❌ Name blockiert</strong><br>
Grund: ${llm.reason}<br>
Konfidenz: ${Math.round(llm.confidence * 100)}%<br>
LLM-Antwort: "${llm.llmResponse}"<br>
Typ: ${llm.matchType}
</div>
`;
} else {
llmStatus = `
<div style="background: #e8f5e8; color: #2e7d32; padding: 0.5rem; border-radius: 3px;">
<strong>✅ Name erlaubt</strong><br>
Grund: ${llm.reason}<br>
Konfidenz: ${Math.round(llm.confidence * 100)}%<br>
LLM-Antwort: "${llm.llmResponse}"<br>
Typ: ${llm.matchType}
</div>
`;
}
resultContent.innerHTML = llmStatus;
resultDiv.style.display = 'block';
// Vergleich mit Blacklist
if (blacklistResult.success) {
const blacklist = blacklistResult.data;
let comparisonStatus = '';
if (blacklist.combined.isBlocked) {
comparisonStatus = `
<div style="background: #fff3e0; color: #f57c00; padding: 0.5rem; border-radius: 3px;">
<strong>⚠️ Name blockiert (${blacklist.combined.source})</strong><br>
Grund: ${blacklist.combined.reason}
</div>
`;
} else {
comparisonStatus = `
<div style="background: #e8f5e8; color: #2e7d32; padding: 0.5rem; border-radius: 3px;">
<strong>✅ Name erlaubt</strong><br>
Sowohl KI als auch Blacklist erlauben den Namen
</div>
`;
}
comparisonContent.innerHTML = comparisonStatus;
comparisonDiv.style.display = 'block';
}
} else {
resultContent.innerHTML = `
<div style="background: #ffebee; color: #c62828; padding: 0.5rem; border-radius: 3px;">
<strong>❌ Fehler beim Testen</strong><br>
${llmResult.message}
</div>
`;
resultDiv.style.display = 'block';
}
}
// LLM-Nachricht anzeigen
function showLLMMessage(message, type) {
const resultDiv = document.getElementById('llmResult');
const resultContent = document.getElementById('llmResultContent');
const color = type === 'error' ? '#c62828' : '#2e7d32';
const bgColor = type === 'error' ? '#ffebee' : '#e8f5e8';
resultContent.innerHTML = `
<div style="background: ${bgColor}; color: ${color}; padding: 0.5rem; border-radius: 3px;">
<strong>${type === 'error' ? '❌' : '✅'} ${message}</strong>
</div>
`;
resultDiv.style.display = 'block';
}