|
|
<!DOCTYPE html> |
|
|
<html> |
|
|
<head> |
|
|
<title>Ollama Chat</title> |
|
|
</head> |
|
|
<body> |
|
|
<div> |
|
|
<h1>Ollama Chat Test</h1> |
|
|
<div> |
|
|
<textarea id="prompt" rows="4" cols="50"></textarea> |
|
|
</div> |
|
|
<button onclick="sendMessage()">Send</button> |
|
|
<div id="response"></div> |
|
|
</div> |
|
|
|
|
|
<script> |
|
|
async function sendMessage() { |
|
|
const prompt = document.getElementById('prompt').value; |
|
|
const response = document.getElementById('response'); |
|
|
response.textContent = 'Loading...'; |
|
|
|
|
|
try { |
|
|
const res = await fetch('/testchat', { |
|
|
method: 'POST', |
|
|
headers: {'Content-Type': 'application/json'}, |
|
|
body: JSON.stringify({prompt}) |
|
|
}); |
|
|
const data = await res.json(); |
|
|
response.textContent = data.response; |
|
|
} catch (err) { |
|
|
response.textContent = 'Error: ' + err; |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</body> |
|
|
</html> |