Subject-Emu-5259's picture
Push NeuralAI project files - training data, scripts, services, knowledge base
38b4eff verified
Raw
History Blame Contribute Delete
936 Bytes
<!DOCTYPE html>
<html>
<head><title>SSE Test</title></head>
<body>
<h1>SSE Test</h1>
<div id="output" style="border: 1px solid #333; padding: 20px; min-height: 100px; white-space: pre-wrap;"></div>
<script>
async function test() {
const resp = await fetch('/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({messages: [{role:'user', content:'hi'}], use_uplink: false})
});
const reader = resp.body.getReader();
const decoder = new TextDecoder();
const out = document.getElementById('output');
let count = 0;
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value, { stream: true });
out.textContent += 'CHUNK ' + (++count) + ': ' + chunk.substring(0, 200) + '\n';
}
out.textContent += '\n=== DONE ===';
}
test().catch(e => out.textContent = 'ERROR: ' + e);
</script>
</body>
</html>