Spaces:
Sleeping
Sleeping
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<script type="module" src="https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js"></script> | |
<title>econ-chat</title> | |
</head> | |
<body> | |
<h1>econ-chat for eLearning</h1> | |
<h2>Metropolen</h2> | |
<div> | |
<form id="question-form"> | |
<input type="text" id="question" placeholder="e.g. Wer ist Martin Keßler?"> | |
<input type="submit" value="Answer"> | |
</form> | |
</div> | |
<div id="result"></div> | |
<script type="module"> | |
import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js"; | |
const client = await Client.connect("gautamethiraj/econ-chat"); | |
document.getElementById('question-form').addEventListener('submit', async function(event) { | |
event.preventDefault(); // Prevent the default form submission | |
const questionInput = document.getElementById('question'); | |
const question = questionInput.value; | |
const resultDiv = document.getElementById('result'); | |
resultDiv.textContent = 'Loading...'; // Show a loading message | |
try { | |
const result = await client.predict("/predict", { | |
frage: question, | |
}); | |
resultDiv.textContent = result.data; // Display the result on the page | |
} catch (error) { | |
resultDiv.textContent = 'An error occurred. Please try again.'; // Handle errors | |
} | |
}); | |
</script> | |
</body> | |
</html> |