DeathDaDev commited on
Commit
dfd6c0b
1 Parent(s): 0686433

feat: create chat interface with live console output section

Browse files
Files changed (1) hide show
  1. templates/index.html +70 -30
templates/index.html CHANGED
@@ -1,36 +1,76 @@
1
  <!DOCTYPE html>
2
- <html>
3
  <head>
4
- <title>Ollama Server</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  </head>
6
  <body>
7
- <h1>Ollama Server Logs</h1>
8
- <pre>
9
- {{ logs }}
10
- </pre>
11
- <h1>API Endpoints</h1>
12
- <ul>
13
- <li><code>/generate</code>: Generate text</li>
14
- <li><code>/chat</code>: Chat with the model</li>
15
- <li><code>/translate</code>: Translate text</li>
16
- <li><code>/summarize</code>: Summarize text</li>
17
- <li><code>/question</code>: Answer a question</li>
18
- <li><code>/completion</code>: Complete text</li>
19
- <li><code>/embedding</code>: Get embeddings for text</li>
20
- </ul>
21
- </body>
22
- </html>
23
- <!DOCTYPE html>
24
- <html>
25
- <head>
26
- <title>Ollama Web Interface</title>
27
- </head>
28
- <body>
29
- <h1>Ollama Web Interface</h1>
30
- <p>Logs: <a href="/logs">View Logs</a></p>
31
- <p>API Endpoints:</p>
32
- <ul>
33
- <li>Generate: <a href="/api/generate">POST /api/generate</a></li>
34
- </ul>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  </body>
36
  </html>
 
1
  <!DOCTYPE html>
2
+ <html lang="en">
3
  <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Chat Interface</title>
7
+ <style>
8
+ #chat-container {
9
+ display: flex;
10
+ flex-direction: column;
11
+ width: 300px;
12
+ margin: 0 auto;
13
+ }
14
+ #chat-box {
15
+ border: 1px solid #ccc;
16
+ padding: 10px;
17
+ height: 200px;
18
+ overflow-y: scroll;
19
+ margin-bottom: 10px;
20
+ }
21
+ #console-output {
22
+ border: 1px solid #ccc;
23
+ padding: 10px;
24
+ height: 200px;
25
+ overflow-y: scroll;
26
+ margin-top: 20px;
27
+ }
28
+ </style>
29
  </head>
30
  <body>
31
+ <h1>Chat Interface</h1>
32
+ <div id="chat-container">
33
+ <div id="chat-box"></div>
34
+ <input type="text" id="chat-input" placeholder="Type your message here...">
35
+ <button id="send-button">Send</button>
36
+ </div>
37
+ <h2>Console Output</h2>
38
+ <div id="console-output"></div>
39
+ <script>
40
+ const chatBox = document.getElementById('chat-box');
41
+ const chatInput = document.getElementById('chat-input');
42
+ const sendButton = document.getElementById('send-button');
43
+ const consoleOutput = document.getElementById('console-output');
44
+
45
+ sendButton.addEventListener('click', () => {
46
+ const message = chatInput.value;
47
+ if (message) {
48
+ fetch('/api/generate', {
49
+ method: 'POST',
50
+ headers: {
51
+ 'Content-Type': 'application/json'
52
+ },
53
+ body: JSON.stringify({ prompt: message })
54
+ })
55
+ .then(response => response.json())
56
+ .then(data => {
57
+ const responseMessage = document.createElement('div');
58
+ responseMessage.textContent = `Bot: ${data.response}`;
59
+ chatBox.appendChild(responseMessage);
60
+ });
61
+ const userMessage = document.createElement('div');
62
+ userMessage.textContent = `You: ${message}`;
63
+ chatBox.appendChild(userMessage);
64
+ chatInput.value = '';
65
+ }
66
+ });
67
+
68
+ const eventSource = new EventSource('/logs');
69
+ eventSource.onmessage = function(event) {
70
+ const logMessage = document.createElement('div');
71
+ logMessage.textContent = event.data;
72
+ consoleOutput.appendChild(logMessage);
73
+ };
74
+ </script>
75
  </body>
76
  </html>