CoolFace
Apppublic

sonygod/flash2

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
chat.html36 linesDownload Raw Back to templates
1<!DOCTYPE html>2<html>3<head>4    <title>Ollama Chat</title>5</head>6<body>7    <div>8        <h1>Ollama Chat Test</h1>9        <div>10            <textarea id="prompt" rows="4" cols="50"></textarea>11        </div>12        <button onclick="sendMessage()">Send</button>13        <div id="response"></div>14    </div>15 16    <script>17        async function sendMessage() {18            const prompt = document.getElementById('prompt').value;19            const response = document.getElementById('response');20            response.textContent = 'Loading...';21 22            try {23                const res = await fetch('/testchat', {24                    method: 'POST',25                    headers: {'Content-Type': 'application/json'},26                    body: JSON.stringify({prompt})27                });28                const data = await res.json();29                response.textContent = data.response;30            } catch (err) {31                response.textContent = 'Error: ' + err;32            }33        }34    </script>35</body>36</html>