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 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;">
Zur besseren Analyse Ihres Szenarios könnten diese Informationen hilfreich sein:
Zur besseren Analyse könnten diese Zusatzinformationen hilfreich sein:
</p>
<div id="questions-list"></div>
<div style="margin-top: 1rem; text-align: right;">
@ -200,7 +200,6 @@ document.addEventListener('DOMContentLoaded', () => {
// Smart prompting state
let enhancementTimeout;
let enhancementAbortController;
let suggestionsVisible = false;
if (!aiInput || !aiSubmitBtn || !aiLoading || !aiError || !aiResults) {
console.error('AI interface elements not found');
@ -259,7 +258,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
// Smart Prompting Functions
// Smart Prompting Functions - Simplified
function showPromptingStatus(state) {
if (!smartPromptingContainer || !promptingStatus || !promptingSpinner) return;
@ -269,29 +268,22 @@ document.addEventListener('DOMContentLoaded', () => {
promptingStatus.textContent = '💡 KI analysiert Ihre Eingabe...';
promptingSpinner.style.display = 'inline-block';
suggestedQuestions.style.display = 'none';
suggestionsVisible = false;
break;
case 'suggestions':
promptingStatus.textContent = '✅ Verbesserungsvorschläge verfügbar';
promptingSpinner.style.display = 'none';
suggestedQuestions.style.display = 'block';
suggestionsVisible = true;
break;
case 'rate-limited':
promptingStatus.textContent = '⏸️ Verbesserungen verfügbar nach Hauptabfrage';
promptingStatus.textContent = '⏸️ Verbesserungen nach Hauptabfrage verfügbar';
promptingSpinner.style.display = 'none';
suggestedQuestions.style.display = 'none';
suggestionsVisible = false;
break;
case 'error':
promptingStatus.textContent = '⚠️ Verbesserungen temporär nicht verfügbar';
promptingSpinner.style.display = 'none';
suggestedQuestions.style.display = 'none';
suggestionsVisible = false;
smartPromptingContainer.style.display = 'none'; // Just hide on error
break;
case 'hidden':
smartPromptingContainer.style.display = 'none';
suggestionsVisible = false;
break;
}
}
@ -306,29 +298,10 @@ document.addEventListener('DOMContentLoaded', () => {
questionElement.className = 'suggestion-item';
questionElement.innerHTML = `
<div style="display: flex; align-items: start; gap: 0.5rem;">
<span class="suggestion-number">${index + 1}.</span>
<span class="suggestion-text">${question}</span>
<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>
<span class="suggestion-number">${index + 1}.</span>
${question}
`;
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);
});
@ -336,7 +309,6 @@ document.addEventListener('DOMContentLoaded', () => {
}
async function triggerSmartPrompting() {
console.log('[DEBUG] triggerSmartPrompting function defined');
const inputText = aiInput.value.trim();
if (inputText.length < 50) {
@ -367,7 +339,6 @@ document.addEventListener('DOMContentLoaded', () => {
});
const data = await response.json();
console.log('[DEBUG AIQuery]Enhancement response:', data);
if (!response.ok) {
if (response.status === 429) {
@ -391,13 +362,6 @@ document.addEventListener('DOMContentLoaded', () => {
console.warn('Smart prompting failed:', 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);
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:
- Betroffene Systeme/Plattformen
- Zeitrahmen/Timeline
- Verfügbare Evidenz
- Verdächtige Aktivitäten
- Technische Details
Wenn die Eingabe bereits klar, spezifisch und vollständig ist, gib stattdessen nur eine leere Liste [] zurück.
Antworte NUR mit einem JSON-Array von 2-3 kurzen Fragen (max. 60 Zeichen pro Frage):
["Frage 1?", "Frage 2?", "Frage 3?"]
Antwortformat strikt:
Keine zusätzlichen Erklärungen.`;
\`\`\`json
[
"Frage 1?",
"Frage 2?",
"Frage 3?"
]
\`\`\`
Nutzer-Eingabe:
${input}
`.trim();
}
export const POST: APIRoute = async ({ request }) => {
try {
const authResult = await withAPIAuth(request, 'ai');
@ -138,13 +144,10 @@ export const POST: APIRoute = async ({ request }) => {
let questions;
try {
// Clean up the response and parse JSON
console.log('[DEBUG-ENHANCE]Raw AI content:', aiContent);
const cleanedContent = aiContent
.replace(/^```json\s*/i, '')
.replace(/\s*```\s*$/, '')
.trim();
console.log('[DEBUG-ENHANCE]Cleaned content:', cleanedContent);
questions = JSON.parse(cleanedContent);
if (!Array.isArray(questions) || questions.length === 0) {
@ -153,7 +156,7 @@ export const POST: APIRoute = async ({ request }) => {
// Validate and clean 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);
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 {
margin-top: 1rem;
animation: slideDown 0.3s ease-out;
animation: smartPromptSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.prompting-status {
@ -1955,33 +1955,34 @@ footer {
border: 1px solid var(--color-border);
border-radius: 0.375rem;
padding: 0.75rem;
cursor: pointer;
transition: var(--transition-fast);
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);
font-weight: bold;
flex-shrink: 0;
font-weight: 600;
margin-right: 0.5rem;
}
.suggestion-item .suggestion-text {
flex: 1;
/* Improved animation - smoother and simpler */
@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 */
.contextual-analysis-card {