From 883e5d7c034703f534d38caafdbafbf1bdddb2b1 Mon Sep 17 00:00:00 2001 From: PleahMaCaka Date: Thu, 2 Nov 2023 11:42:29 +0900 Subject: [PATCH] chore: make clean debug logging --- src/lib/client/Client.ts | 17 ++++++++-------- .../chat/messages/AssistantMessage.svelte | 20 +++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/lib/client/Client.ts b/src/lib/client/Client.ts index 6e3f325..97ac62d 100644 --- a/src/lib/client/Client.ts +++ b/src/lib/client/Client.ts @@ -5,7 +5,7 @@ import axios from "axios" import { Client as LLM } from "booga.js" import { get } from "svelte/store" -export class Client { +export const client = new class Client { private _modelUrl: string = get(stateStore).url.model private _serverUrl: string = get(stateStore).url.server @@ -59,9 +59,9 @@ export class Client { // TODO get char/inst/preset from settings and/or env vars public async send( msg: string, - char: string = "Commander V3", - inst: string = "Commander V3", - preset: string = "Commander V3" + char: string = "Commander", + inst: string = "Commander", + preset: string = "Commander" ) { this.updateModelUrl() @@ -77,8 +77,6 @@ export class Client { preset: preset, mode: "chat-instruct" }).then(async (res) => { - if (get(stateStore).debug) - console.log("Response: ", res) await this.removeLastHistory() await this.appendHistory(Author.Assistant, res) }) @@ -89,6 +87,9 @@ export class Client { return await this._axios.get(`${this._serverUrl}/service/weather`).then(res => res.data) } -} -export const client = new Client() + public async translateToKr(content: string): Promise { + return await this._axios.post(`${this._serverUrl}/service/translate/toKr`, content).then(res => res.data) + } + +} diff --git a/src/lib/components/chat/messages/AssistantMessage.svelte b/src/lib/components/chat/messages/AssistantMessage.svelte index 48fc431..c7f1e40 100644 --- a/src/lib/components/chat/messages/AssistantMessage.svelte +++ b/src/lib/components/chat/messages/AssistantMessage.svelte @@ -63,15 +63,19 @@ feature = getFeature(command) // debug and last processing stuffs - if (get(stateStore).debug) - console.log("Assisting!", { - message, - commands: raw_commands, - args, - command, - "feature": feature, - }) executed = true + + if (get(stateStore).debug) + if (message === "...") console.log("Waiting for response...") + else { + console.log("Assisting!", { + message, + commands: raw_commands, + args, + command, + "feature": feature, + }) + } })