server : simple chat UI with vuejs and daisyui
This commit is contained in:
parent
ea02c753eb
commit
120d05b7de
2 changed files with 160 additions and 1292 deletions
|
@ -29,7 +29,7 @@ export async function* llama(prompt, params = {}, config = {}) {
|
||||||
|
|
||||||
const completionParams = { ...paramDefaults, ...params, prompt };
|
const completionParams = { ...paramDefaults, ...params, prompt };
|
||||||
|
|
||||||
const response = await fetch(`${api_url}/completion`, {
|
const response = await fetch(`${api_url}${config.endpoint || '/completion'}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(completionParams),
|
body: JSON.stringify(completionParams),
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -78,7 +78,12 @@ export async function* llama(prompt, params = {}, config = {}) {
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const match = regex.exec(line);
|
const match = regex.exec(line);
|
||||||
if (match) {
|
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
|
// since we know this is llama.cpp, let's just decode the json in data
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
result.data = JSON.parse(result.data);
|
result.data = JSON.parse(result.data);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue