diff --git a/client/forge.config.ts b/client/forge.config.ts index 35d03860..ace7d900 100644 --- a/client/forge.config.ts +++ b/client/forge.config.ts @@ -12,6 +12,7 @@ import { rendererConfig } from './webpack.renderer.config' const config: ForgeConfig = { packagerConfig: { asar: true, + icon: './images/icon', }, rebuildConfig: {}, makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin']), new MakerRpm({}), new MakerDeb({})], diff --git a/client/images/icon.icns b/client/images/icon.icns new file mode 100644 index 00000000..ad9a1819 Binary files /dev/null and b/client/images/icon.icns differ diff --git a/client/src/app.css b/client/src/app.css index 47d8f540..af1ebf96 100644 --- a/client/src/app.css +++ b/client/src/app.css @@ -8,5 +8,5 @@ body { } .drag { - -webkit-app-region: deag; + -webkit-app-region: drag; } diff --git a/client/src/app.tsx b/client/src/app.tsx index 0b504ef6..bf675ddf 100644 --- a/client/src/app.tsx +++ b/client/src/app.tsx @@ -1,6 +1,6 @@ import { useState } from 'react' -const API_URL = 'http://127.0.0.1:8080' +const API_URL = 'http://127.0.0.1:5000' type Message = { sender: string @@ -8,16 +8,18 @@ type Message = { } async function completion(prompt: string, callback: (res: string) => void) { - const result = await fetch(`${API_URL}/completion`, { + const result = await fetch(`${API_URL}/generate`, { method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, body: JSON.stringify({ - prompt: prompt, - temperature: 0.2, - top_k: 40, - top_p: 0.9, - n_predict: 256, - stop: ['\n### Human:'], // stop completion after generating this - stream: true, + prompt: `A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions. + + ### Human: Hello, Assistant. + ### Assistant: Hello. How may I help you today? + ### Human: ${prompt}`, + model: 'ggml-model-q4_0', }), }) @@ -36,12 +38,17 @@ async function completion(prompt: string, callback: (res: string) => void) { let decoder = new TextDecoder() let str = decoder.decode(value) - if (str.startsWith('data: ')) { - const message = JSON.parse(str.substring(6)) - callback(message.content) - if (message.stop) { + let re = /}{/g + str = '[' + str.replace(re, '},{') + ']' + let messages = JSON.parse(str) + + for (const message of messages) { + const choice = message.choices[0] + if (choice.finish_reason === 'stop') { break } + + callback(choice.text) } } @@ -63,10 +70,20 @@ export default function () {
{messages.map((m, i) => (
-
{m.sender === 'human' ? '👩' : '🤖'}
+
+ {m.sender === 'human' ? ( +
+ H +
+ ) : ( +
+ L +
+ )} +
{m.content} - {m.sender === 'bot' && ⬤} + {m.sender === 'bot' && ⬤}
))} diff --git a/client/src/index.ts b/client/src/index.ts index a4694de5..0a1ca3d2 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -39,9 +39,6 @@ const createWindow = (): void => { // and load the index.html of the app. mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY) - - // Open the DevTools. - mainWindow.webContents.openDevTools() } // This method will be called when Electron has finished