From 3e2311c4eae26c09e212a3063ea94681af2a58cb Mon Sep 17 00:00:00 2001 From: PleahMaCaka Date: Tue, 31 Oct 2023 14:44:43 +0900 Subject: [PATCH] feat(client): placeholder message until a waiting message --- src/lib/client/Client.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib/client/Client.ts b/src/lib/client/Client.ts index cffa463..9d09f76 100644 --- a/src/lib/client/Client.ts +++ b/src/lib/client/Client.ts @@ -32,8 +32,17 @@ export class Client { }) } + // not tested + public async removeLastHistory() { + stateStore.update((state) => { + return { + ...state, + history: state.history.slice(0, -1) + } + }) + } - // TODO get char/inst/preset from settings and/or env vars +// TODO get char/inst/preset from settings and/or env vars public async send( msg: string, char: string = "Commander V3", @@ -46,14 +55,18 @@ export class Client { return // TODO do something for empty url await this.appendHistory(Author.User, msg) + await this.appendHistory(Author.Assistant, "...") // TODO add loading animation or anything blabla await this.llm.chat(msg, { character: char, instruction_template: inst, preset: preset, mode: "chat-instruct" - }).then(res => { - this.appendHistory(Author.Assistant, res) + }).then(async (res) => { + if (get(stateStore).debug) + console.log("Response: ", res) + await this.removeLastHistory() + await this.appendHistory(Author.Assistant, res) }) }