From b6c3ec12f0ec368cbdb534088a61446c6e95c143 Mon Sep 17 00:00:00 2001 From: PleahMaCaka Date: Thu, 26 Oct 2023 14:31:05 +0900 Subject: [PATCH] fix: reactive update url update --- src/lib/client/Client.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lib/client/Client.ts b/src/lib/client/Client.ts index c5d7dff..65b510c 100644 --- a/src/lib/client/Client.ts +++ b/src/lib/client/Client.ts @@ -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 { @@ -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, {