researcher / static /index.html
sccastillo's picture
update
476e500
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FastAPI TextGen - Development Interface</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 2.5em;
margin-bottom: 10px;
}
.header p {
font-size: 1.1em;
opacity: 0.9;
}
.content {
padding: 40px;
}
.form-group {
margin-bottom: 25px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #333;
}
#questionInput {
width: 100%;
padding: 15px;
border: 2px solid #e1e5e9;
border-radius: 8px;
font-size: 16px;
transition: border-color 0.3s;
resize: vertical;
min-height: 100px;
}
#questionInput:focus {
outline: none;
border-color: #4facfe;
}
#askButton {
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
color: white;
padding: 15px 30px;
border: none;
border-radius: 8px;
font-size: 18px;
cursor: pointer;
transition: transform 0.2s;
width: 100%;
}
#askButton:hover {
transform: translateY(-2px);
}
#askButton:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.response-section {
margin-top: 30px;
}
#responseContainer {
background: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 8px;
padding: 20px;
min-height: 100px;
white-space: pre-wrap;
line-height: 1.6;
}
.loading {
text-align: center;
color: #6c757d;
font-style: italic;
}
.error {
color: #dc3545;
background: #f8d7da;
border-color: #f5c6cb;
}
.examples {
margin-top: 20px;
padding: 20px;
background: #e3f2fd;
border-radius: 8px;
}
.examples h3 {
color: #1976d2;
margin-bottom: 15px;
}
.example-question {
background: white;
padding: 10px;
margin: 5px 0;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.2s;
}
.example-question:hover {
background: #f5f5f5;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🤖 FastAPI TextGen</h1>
<p>Development Interface - Ask any question!</p>
</div>
<div class="content">
<form id="questionForm">
<div class="form-group">
<label for="questionInput">Your Question:</label>
<textarea
id="questionInput"
placeholder="Ask me anything... For example: 'What is artificial intelligence?' or 'Explain quantum computing in simple terms'"
required
></textarea>
</div>
<button type="submit" id="askButton">Ask Question</button>
</form>
<div class="response-section">
<label>Response:</label>
<div id="responseContainer">
Ready to answer your questions! Type a question above and click "Ask Question".
</div>
</div>
<div class="examples">
<h3>💡 Example Questions</h3>
<div class="example-question" onclick="setQuestion('What is machine learning?')">
What is machine learning?
</div>
<div class="example-question" onclick="setQuestion('Explain the difference between AI and machine learning')">
Explain the difference between AI and machine learning
</div>
<div class="example-question" onclick="setQuestion('How does a neural network work?')">
How does a neural network work?
</div>
<div class="example-question" onclick="setQuestion('What are the benefits of cloud computing?')">
What are the benefits of cloud computing?
</div>
</div>
</div>
</div>
<script>
const questionForm = document.getElementById('questionForm');
const questionInput = document.getElementById('questionInput');
const askButton = document.getElementById('askButton');
const responseContainer = document.getElementById('responseContainer');
function setQuestion(question) {
questionInput.value = question;
questionInput.focus();
}
questionForm.addEventListener('submit', async (e) => {
e.preventDefault();
const question = questionInput.value.trim();
if (!question) return;
// Show loading state
askButton.disabled = true;
askButton.textContent = 'Thinking...';
responseContainer.className = 'loading';
responseContainer.textContent = '🤔 Processing your question...';
try {
const response = await fetch('/api/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ question: question }),
});
const data = await response.json();
if (response.ok) {
responseContainer.className = '';
responseContainer.textContent = data.text;
} else {
throw new Error(data.detail || 'Something went wrong');
}
} catch (error) {
responseContainer.className = 'error';
responseContainer.textContent = `Error: ${error.message}`;
} finally {
askButton.disabled = false;
askButton.textContent = 'Ask Question';
}
});
</script>
</body>
</html>