From 120d05b7dec4393db65cc6dd1c194ca583e24d8c Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Mon, 4 Nov 2024 23:09:57 +0100 Subject: [PATCH] server : simple chat UI with vuejs and daisyui --- examples/server/public/completion.js | 9 +- examples/server/public/index.html | 1443 +++----------------------- 2 files changed, 160 insertions(+), 1292 deletions(-) diff --git a/examples/server/public/completion.js b/examples/server/public/completion.js index 36818f764..30df7c2fa 100644 --- a/examples/server/public/completion.js +++ b/examples/server/public/completion.js @@ -29,7 +29,7 @@ export async function* llama(prompt, params = {}, config = {}) { const completionParams = { ...paramDefaults, ...params, prompt }; - const response = await fetch(`${api_url}/completion`, { + const response = await fetch(`${api_url}${config.endpoint || '/completion'}`, { method: 'POST', body: JSON.stringify(completionParams), headers: { @@ -78,7 +78,12 @@ export async function* llama(prompt, params = {}, config = {}) { for (const line of lines) { const match = regex.exec(line); if (match) { - result[match[1]] = match[2] + result[match[1]] = match[2]; + if (result.data === '[DONE]') { + cont = false; + break; + } + // since we know this is llama.cpp, let's just decode the json in data if (result.data) { result.data = JSON.parse(result.data); diff --git a/examples/server/public/index.html b/examples/server/public/index.html index a95f5c6df..df9de687d 100644 --- a/examples/server/public/index.html +++ b/examples/server/public/index.html @@ -3,1301 +3,164 @@ - llama.cpp - chat + 🦙 llama.cpp - chat - - - + + + -
- +
+
+ +
+
+ 🦙 llama.cpp - chat +
+
+ + +
+
+ + +
+
+ + {{ messages.length === 0 ? 'Send a message to start' : '' }} +
+
+
+

{{ line }}

+
+
+ + +
+
+ +

{{ line }}

+
+
+
+ + +
+ + +
+
-
+ +