This commit is contained in:
overcuriousity 2025-07-26 22:27:29 +02:00
parent 3eb1b9d8d7
commit 69aa19642c
3 changed files with 46 additions and 78 deletions

View File

@ -66,7 +66,7 @@ const domainAgnosticSoftware = data['domain-agnostic-software'] || [];
</div> </div>
<div id="suggested-questions" class="suggested-questions" style="display: none;"> <div id="suggested-questions" class="suggested-questions" style="display: none;">
<p style="margin: 0 0 0.75rem 0; font-size: 0.875rem; color: var(--color-text-secondary); line-height: 1.5;"> <p style="margin: 0 0 0.75rem 0; font-size: 0.875rem; color: var(--color-text-secondary); line-height: 1.5;">
Zur besseren Analyse Ihres Szenarios könnten diese Informationen hilfreich sein: Zur besseren Analyse könnten diese Zusatzinformationen hilfreich sein:
</p> </p>
<div id="questions-list"></div> <div id="questions-list"></div>
<div style="margin-top: 1rem; text-align: right;"> <div style="margin-top: 1rem; text-align: right;">
@ -200,7 +200,6 @@ document.addEventListener('DOMContentLoaded', () => {
// Smart prompting state // Smart prompting state
let enhancementTimeout; let enhancementTimeout;
let enhancementAbortController; let enhancementAbortController;
let suggestionsVisible = false;
if (!aiInput || !aiSubmitBtn || !aiLoading || !aiError || !aiResults) { if (!aiInput || !aiSubmitBtn || !aiLoading || !aiError || !aiResults) {
console.error('AI interface elements not found'); console.error('AI interface elements not found');
@ -259,7 +258,7 @@ document.addEventListener('DOMContentLoaded', () => {
} }
} }
// Smart Prompting Functions // Smart Prompting Functions - Simplified
function showPromptingStatus(state) { function showPromptingStatus(state) {
if (!smartPromptingContainer || !promptingStatus || !promptingSpinner) return; if (!smartPromptingContainer || !promptingStatus || !promptingSpinner) return;
@ -269,29 +268,22 @@ document.addEventListener('DOMContentLoaded', () => {
promptingStatus.textContent = '💡 KI analysiert Ihre Eingabe...'; promptingStatus.textContent = '💡 KI analysiert Ihre Eingabe...';
promptingSpinner.style.display = 'inline-block'; promptingSpinner.style.display = 'inline-block';
suggestedQuestions.style.display = 'none'; suggestedQuestions.style.display = 'none';
suggestionsVisible = false;
break; break;
case 'suggestions': case 'suggestions':
promptingStatus.textContent = '✅ Verbesserungsvorschläge verfügbar'; promptingStatus.textContent = '✅ Verbesserungsvorschläge verfügbar';
promptingSpinner.style.display = 'none'; promptingSpinner.style.display = 'none';
suggestedQuestions.style.display = 'block'; suggestedQuestions.style.display = 'block';
suggestionsVisible = true;
break; break;
case 'rate-limited': case 'rate-limited':
promptingStatus.textContent = '⏸️ Verbesserungen verfügbar nach Hauptabfrage'; promptingStatus.textContent = '⏸️ Verbesserungen nach Hauptabfrage verfügbar';
promptingSpinner.style.display = 'none'; promptingSpinner.style.display = 'none';
suggestedQuestions.style.display = 'none'; suggestedQuestions.style.display = 'none';
suggestionsVisible = false;
break; break;
case 'error': case 'error':
promptingStatus.textContent = '⚠️ Verbesserungen temporär nicht verfügbar'; smartPromptingContainer.style.display = 'none'; // Just hide on error
promptingSpinner.style.display = 'none';
suggestedQuestions.style.display = 'none';
suggestionsVisible = false;
break; break;
case 'hidden': case 'hidden':
smartPromptingContainer.style.display = 'none'; smartPromptingContainer.style.display = 'none';
suggestionsVisible = false;
break; break;
} }
} }
@ -306,29 +298,10 @@ document.addEventListener('DOMContentLoaded', () => {
questionElement.className = 'suggestion-item'; questionElement.className = 'suggestion-item';
questionElement.innerHTML = ` questionElement.innerHTML = `
<div style="display: flex; align-items: start; gap: 0.5rem;">
<span class="suggestion-number">${index + 1}.</span> <span class="suggestion-number">${index + 1}.</span>
<span class="suggestion-text">${question}</span> ${question}
<svg class="suggestion-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="12" y1="5" x2="12" y2="19"/>
<line x1="5" y1="12" x2="19" y2="12"/>
</svg>
</div>
`; `;
questionElement.addEventListener('click', () => {
const currentText = aiInput.value.trim();
const newText = currentText ? `${currentText}\n\n${question}` : question;
aiInput.value = newText;
aiInput.focus();
// Trigger input event to update character counter
aiInput.dispatchEvent(new Event('input', { bubbles: true }));
// Hide suggestions after adding
showPromptingStatus('hidden');
});
questionsList.appendChild(questionElement); questionsList.appendChild(questionElement);
}); });
@ -336,7 +309,6 @@ document.addEventListener('DOMContentLoaded', () => {
} }
async function triggerSmartPrompting() { async function triggerSmartPrompting() {
console.log('[DEBUG] triggerSmartPrompting function defined');
const inputText = aiInput.value.trim(); const inputText = aiInput.value.trim();
if (inputText.length < 50) { if (inputText.length < 50) {
@ -367,7 +339,6 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
const data = await response.json(); const data = await response.json();
console.log('[DEBUG AIQuery]Enhancement response:', data);
if (!response.ok) { if (!response.ok) {
if (response.status === 429) { if (response.status === 429) {
@ -391,13 +362,6 @@ document.addEventListener('DOMContentLoaded', () => {
console.warn('Smart prompting failed:', error); console.warn('Smart prompting failed:', error);
showPromptingStatus('error'); showPromptingStatus('error');
// Auto-hide error after 3 seconds
setTimeout(() => {
if (promptingStatus && promptingStatus.textContent.includes('nicht verfügbar')) {
showPromptingStatus('hidden');
}
}, 3000);
} }
} }

View File

@ -59,23 +59,29 @@ function cleanupExpiredRateLimits() {
setInterval(cleanupExpiredRateLimits, 5 * 60 * 1000); setInterval(cleanupExpiredRateLimits, 5 * 60 * 1000);
function createEnhancementPrompt(input: string): string { function createEnhancementPrompt(input: string): string {
return `Analysiere diese forensische Szenario-Beschreibung und schlage 2-3 kurze, präzise Fragen vor, die dem Nutzer helfen würden, vollständigere Informationen zu liefern. return `
Du bist eine KI für digitale Forensik. Der Nutzer beschreibt ein forensisches Szenario. Analysiere die Eingabe.
Nutzer-Eingabe: "${input}" Wenn die Beschreibung unvollständig oder vage ist, stelle bis zu drei präzise Rückfragen im JSON-Array-Format, um wichtige Details zu klären (z.B. Vorfalltyp, System, Ziel, Datenquellen, Zeit, Beteiligte, rechtlicher Rahmen).
Konzentriere dich auf wichtige Details die für eine forensische Untersuchung relevant sind: Wenn die Eingabe bereits klar, spezifisch und vollständig ist, gib stattdessen nur eine leere Liste [] zurück.
- Betroffene Systeme/Plattformen
- Zeitrahmen/Timeline
- Verfügbare Evidenz
- Verdächtige Aktivitäten
- Technische Details
Antworte NUR mit einem JSON-Array von 2-3 kurzen Fragen (max. 60 Zeichen pro Frage): Antwortformat strikt:
["Frage 1?", "Frage 2?", "Frage 3?"]
Keine zusätzlichen Erklärungen.`; \`\`\`json
[
"Frage 1?",
"Frage 2?",
"Frage 3?"
]
\`\`\`
Nutzer-Eingabe:
${input}
`.trim();
} }
export const POST: APIRoute = async ({ request }) => { export const POST: APIRoute = async ({ request }) => {
try { try {
const authResult = await withAPIAuth(request, 'ai'); const authResult = await withAPIAuth(request, 'ai');
@ -138,13 +144,10 @@ export const POST: APIRoute = async ({ request }) => {
let questions; let questions;
try { try {
// Clean up the response and parse JSON
console.log('[DEBUG-ENHANCE]Raw AI content:', aiContent);
const cleanedContent = aiContent const cleanedContent = aiContent
.replace(/^```json\s*/i, '') .replace(/^```json\s*/i, '')
.replace(/\s*```\s*$/, '') .replace(/\s*```\s*$/, '')
.trim(); .trim();
console.log('[DEBUG-ENHANCE]Cleaned content:', cleanedContent);
questions = JSON.parse(cleanedContent); questions = JSON.parse(cleanedContent);
if (!Array.isArray(questions) || questions.length === 0) { if (!Array.isArray(questions) || questions.length === 0) {
@ -153,7 +156,7 @@ export const POST: APIRoute = async ({ request }) => {
// Validate and clean questions // Validate and clean questions
questions = questions questions = questions
.filter(q => typeof q === 'string' && q.length > 5 && q.length < 100) .filter(q => typeof q === 'string' && q.length > 5 && q.length < 120)
.slice(0, 3); .slice(0, 3);
if (questions.length === 0) { if (questions.length === 0) {

View File

@ -1924,10 +1924,10 @@ footer {
} }
} }
/* Add to global.css - Smart Prompting Styles */ /* Smart Prompting Styles - Simplified */
.smart-prompting-container { .smart-prompting-container {
margin-top: 1rem; margin-top: 1rem;
animation: slideDown 0.3s ease-out; animation: smartPromptSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
} }
.prompting-status { .prompting-status {
@ -1955,33 +1955,34 @@ footer {
border: 1px solid var(--color-border); border: 1px solid var(--color-border);
border-radius: 0.375rem; border-radius: 0.375rem;
padding: 0.75rem; padding: 0.75rem;
cursor: pointer;
transition: var(--transition-fast);
font-size: 0.875rem; font-size: 0.875rem;
line-height: 1.4; line-height: 1.5;
color: var(--color-text);
border-left: 3px solid var(--color-accent);
transition: var(--transition-fast);
} }
.suggestion-item:hover {
background-color: var(--color-bg-tertiary);
border-color: var(--color-accent);
}
.suggestion-item .suggestion-number { .suggestion-number {
color: var(--color-accent); color: var(--color-accent);
font-weight: bold; font-weight: 600;
flex-shrink: 0;
margin-right: 0.5rem; margin-right: 0.5rem;
} }
.suggestion-item .suggestion-text { /* Improved animation - smoother and simpler */
flex: 1; @keyframes smartPromptSlideIn {
from {
opacity: 0;
transform: translateY(-10px);
max-height: 0;
}
to {
opacity: 1;
transform: translateY(0);
max-height: 200px;
}
} }
.suggestion-item .suggestion-icon {
flex-shrink: 0;
margin-left: 0.5rem;
color: var(--color-text-secondary);
}
/* Enhanced contextual analysis cards */ /* Enhanced contextual analysis cards */
.contextual-analysis-card { .contextual-analysis-card {