summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Douillet <vincent@vdouillet.fr>2025-06-28 17:52:19 +0200
committerVincent Douillet <vincent@vdouillet.fr>2025-06-28 17:52:19 +0200
commit6b6378b3caccc321fefb4e24726c22ecb62a1d5e (patch)
treeaa1a76478ac01c7548d5b73a8b1c512f751dbf1d
first commit
-rw-r--r--index.html70
1 files changed, 70 insertions, 0 deletions
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..ad1c540
--- /dev/null
+++ b/index.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta charset="UTF-8">
+ <title>A(I)MA - A(I)sk me anything!</title>
+ <style>
+ div#chat>p {
+ width: 100%;
+ }
+ </style>
+</head>
+
+<body style="margin: 0;">
+ <main
+ style="display: flex; flex-direction: column; justify-content: space-between; height: 100vh; align-items: center;">
+ <h1 style="text-align: center;">A(I)MA - A(I)sk me anything!</h1>
+ <div id="chat" style="padding: 20px; width: 80%; justify-content: center;">
+ <p id="placeholder">Ask below :-)</p>
+ </div>
+ <form style="display: flex; justify-content: center; align-items: center; padding: 20px; width: 80%">
+ <input id="prompt" type="text" placeholder="Enter your message here"
+ style="padding: 10px; width: 100%; margin-right: 10px;">
+ <button id="send" type="submit" style="padding: 10px;">Send</button>
+ </form>
+ </main>
+ <script>
+ var firstCall = true;
+ const chat = document.getElementById('chat');
+ const prompt = document.getElementById('prompt');
+ const send = document.getElementById('send');
+ send.addEventListener('click', e => {
+ e.preventDefault();
+
+ // clear chat on first call
+ if (firstCall) {
+ firstCall = false;
+ const placeholder = document.getElementById('placeholder');
+ placeholder.parentNode.removeChild(placeholder);
+ }
+
+ // clear prompt on submit
+ const promptValue = prompt.value;
+ prompt.value = '';
+
+ // append request to the chat
+ appendChat("> " + promptValue);
+
+ // call the api
+ fetch('http://localhost:11434/api/generate', {
+ method: 'POST',
+ body: JSON.stringify({
+ model: "codegemma:7b",
+ prompt: promptValue,
+ stream: false
+ })
+ })
+ .then(response => response.json())
+ .then(data => appendChat(data.response))
+ .catch(error => console.error(error));
+ });
+ function appendChat(message) {
+ const messageDisplay = document.createElement('p');
+ messageDisplay.textContent = message;
+ chat.appendChild(messageDisplay);
+ }
+ </script>
+</body>
+
+</html> \ No newline at end of file