Spaces:
Runtime error
Runtime error
File size: 1,069 Bytes
8158335 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
const generateButton = document.getElementById('generate');
generateButton.addEventListener('click', async () => {
const accountSelect = document.getElementById('account');
const account = accountSelect.options[accountSelect.selectedIndex].value;
const inputText = document.getElementById('input').value;
const outputTextArea = document.getElementById('output');
outputTextArea.value = 'Loading and running model...';
try {
const response = await fetch('/api/generate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ account: account, text: inputText })
});
if (!response.ok) {
throw new Error(`Network response was not ok. Status: ${response.status} - ${response.statusText}`);
}
const data = await response.json();
const outputText = data.generated_text;
document.getElementById('output').value = outputText;
} catch (error) {
console.error('Error:', error);
outputTextArea.value = `Failed to fetch data. Reason: ${error.message}`;
}
}); |