Skip to content

Commit

Permalink
feat(client): placeholder message until a waiting message
Browse files Browse the repository at this point in the history
  • Loading branch information
PleahMaCaka committed Oct 31, 2023
1 parent eaf9860 commit 3e2311c
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/lib/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
})
}

Expand Down

0 comments on commit 3e2311c

Please sign in to comment.