Skip to content

Commit

Permalink
fix: reactive update url update
Browse files Browse the repository at this point in the history
  • Loading branch information
PleahMaCaka committed Oct 26, 2023
1 parent 8b6b7e6 commit b6c3ec1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/lib/client/Client.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { stateStore } from "$lib/stores/StateStore"
import { Author } from "$lib/types/Chat"
import { Client as LLM } from "booga.js"
import { get } from "svelte/store"

export class Client {

private _url: string = ""
public llm = new LLM({
uri: this._url
})
private _url: string = get(stateStore).url.model

constructor() {
stateStore.subscribe((state) => {
this._url = state.url.model
public updateUrl(): void {
this._url = get(stateStore).url.model
this.llm = new LLM({
uri: this._url
})
}

public llm = new LLM({uri: this._url})

constructor() {}

public async appendHistory(author: Author, msg: string) {
stateStore.update((state) => {
return {
Expand All @@ -32,6 +35,8 @@ export class Client {


public async send(msg: string, char: string = "Commander") {
this.updateUrl()

await this.appendHistory(Author.User, msg)

await this.llm.chat(msg, {
Expand Down

0 comments on commit b6c3ec1

Please sign in to comment.