Files
2025-05-11 21:09:46 +03:00

188 lines
9.0 KiB
HTML

<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pre-historic Knowledge Assistant</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
/* Custom animations */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.fade-in {
animation: fadeIn 0.5s ease-out;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #94a3b8;
}
</style>
</head>
<body class="h-full bg-gradient-to-br from-slate-50 to-slate-100">
<div class="min-h-full flex flex-col">
<!-- Header -->
<header class="bg-white border-b border-slate-200 sticky top-0 z-10 backdrop-blur-sm bg-white/90">
<div class="max-w-3xl mx-auto px-4 py-4">
<h1 class="text-2xl font-bold text-slate-900 flex items-center gap-2">
<svg class="w-8 h-8 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"></path>
</svg>
Pre-historic Knowledge Assistant
</h1>
</div>
</header>
<!-- Main Content -->
<main class="flex-1 max-w-3xl w-full mx-auto px-4 py-8">
{% if error %}
<div class="mb-6 p-4 bg-red-50 border border-red-200 rounded-lg fade-in">
<p class="text-red-700 flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
{{ error }}
</p>
</div>
{% endif %}
<!-- Question Form -->
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-6 mb-6">
<form action="/ask" method="POST" class="space-y-4">
<div>
<label for="question" class="block text-sm font-medium text-slate-700 mb-2">
Ask your question
</label>
<textarea
id="question"
name="question"
rows="3"
required
placeholder="What would you like to know?"
class="w-full px-4 py-3 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none transition duration-200 placeholder-slate-400"
>{{ question if question else '' }}</textarea>
</div>
<button
type="submit"
class="w-full sm:w-auto px-6 py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition duration-200 flex items-center justify-center gap-2"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path>
</svg>
Ask Question
</button>
</form>
</div>
<!-- Loading State -->
<div id="loading-state" class="bg-white rounded-xl shadow-sm border border-slate-200 p-6 hidden">
<div class="flex items-center justify-center gap-3">
<svg class="animate-spin h-5 w-5 text-blue-600" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<p class="text-slate-600">Processing your question...</p>
</div>
</div>
<!-- Answer Display -->
{% if answer %}
<div id="answer-container" class="bg-white rounded-xl shadow-sm border border-slate-200 p-6 fade-in">
<div class="flex items-start gap-3 mb-3">
<div class="flex-shrink-0">
<svg class="w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
</div>
<div class="flex-1">
<h3 class="text-lg font-semibold text-slate-900 mb-2">Answer</h3>
<div class="prose prose-slate max-w-none">
<p class="text-slate-700 leading-relaxed whitespace-pre-wrap">{{ answer }}</p>
</div>
</div>
</div>
</div>
{% endif %}
</main>
<!-- Footer -->
<footer class="bg-white border-t border-slate-200 mt-8">
<div class="max-w-3xl mx-auto px-4 py-4">
<p class="text-center text-sm text-slate-500">
Powered by GraphRAG based LLM Agents 🤖
</p>
</div>
</footer>
</div>
<script>
// Show loading state on form submission
document.querySelector('form').addEventListener('submit', function(e) {
// Find or create loading state
let loadingState = document.getElementById('loading-state');
// If loading state doesn't exist, create it
if (!loadingState) {
const loadingHTML = `
<div id="loading-state" class="bg-white rounded-xl shadow-sm border border-slate-200 p-6 fade-in">
<div class="flex items-center justify-center gap-3">
<svg class="animate-spin h-5 w-5 text-blue-600" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<p class="text-slate-600">Processing your question...</p>
</div>
</div>
`;
// Find the main element and append loading state
const main = document.querySelector('main');
const formContainer = document.querySelector('.bg-white.rounded-xl.shadow-sm.border.border-slate-200.p-6.mb-6');
formContainer.insertAdjacentHTML('afterend', loadingHTML);
loadingState = document.getElementById('loading-state');
} else {
// Show existing loading state
loadingState.style.display = 'block';
loadingState.classList.remove('hidden');
}
// Hide any existing answer container
const answerContainer = document.getElementById('answer-container');
if (answerContainer) {
answerContainer.style.display = 'none';
}
// Smooth scroll to the loading state
setTimeout(() => {
loadingState.scrollIntoView({ behavior: 'smooth', block: 'center' });
}, 100);
});
// Auto-resize textarea
const textarea = document.querySelector('textarea');
textarea.addEventListener('input', function() {
this.style.height = 'auto';
this.style.height = this.scrollHeight + 'px';
});
// Handle Enter key for form submission and Shift+Enter for new line
textarea.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
this.closest('form').submit();
}
});
</script>
</body>
</html>