Skip to content

Commit

Permalink
server : simple chat UI with vuejs and daisyui
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Nov 4, 2024
1 parent ea02c75 commit 120d05b
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 1,284 deletions.
9 changes: 7 additions & 2 deletions examples/server/public/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 120d05b

Please sign in to comment.