Skip to content

Commit 120d05b

Browse files
committed
server : simple chat UI with vuejs and daisyui
1 parent ea02c75 commit 120d05b

File tree

2 files changed

+152
-1284
lines changed

2 files changed

+152
-1284
lines changed

examples/server/public/completion.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function* llama(prompt, params = {}, config = {}) {
2929

3030
const completionParams = { ...paramDefaults, ...params, prompt };
3131

32-
const response = await fetch(`${api_url}/completion`, {
32+
const response = await fetch(`${api_url}${config.endpoint || '/completion'}`, {
3333
method: 'POST',
3434
body: JSON.stringify(completionParams),
3535
headers: {
@@ -78,7 +78,12 @@ export async function* llama(prompt, params = {}, config = {}) {
7878
for (const line of lines) {
7979
const match = regex.exec(line);
8080
if (match) {
81-
result[match[1]] = match[2]
81+
result[match[1]] = match[2];
82+
if (result.data === '[DONE]') {
83+
cont = false;
84+
break;
85+
}
86+
8287
// since we know this is llama.cpp, let's just decode the json in data
8388
if (result.data) {
8489
result.data = JSON.parse(result.data);

0 commit comments

Comments
 (0)