From 0172b20207ee876713343b35392e20371f599002 Mon Sep 17 00:00:00 2001 From: JOLIMAITRE Matthieu Date: Wed, 28 May 2025 19:02:59 +0200 Subject: [PATCH] Improve logging. --- src/lib/history.ts | 2 ++ src/lib/session.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/history.ts b/src/lib/history.ts index 94dc99a..ad15cdf 100644 --- a/src/lib/history.ts +++ b/src/lib/history.ts @@ -14,6 +14,7 @@ export class History { } public static async load(path: string, limit: number) { + console.log("Loading history from", path) try { const content = await Deno.readTextFile(path) const { messages } = JSON.parse(content) @@ -25,6 +26,7 @@ export class History { } public static async create(path: string, limit: number) { + console.log("Creating history at", path) const result = new History([], path, limit) await result.save() return result diff --git a/src/lib/session.ts b/src/lib/session.ts index 280e7e6..eff7fd7 100644 --- a/src/lib/session.ts +++ b/src/lib/session.ts @@ -24,14 +24,14 @@ export async function session(conn: Deno.TcpConn, name: string, history: History for await (const line of lines) { if (line === "") continue if (line.length > 10_000) return - console.log("user", conn.remoteAddr.hostname, "promoted", line) + console.log("user", conn.remoteAddr.hostname, "prompted", line) if (line.startsWith("/nick ")) { name = line.slice("/nick ".length) console.log("Changed name of", conn.remoteAddr.hostname, "to", name) await write_encoded(conn, "\n> ") continue } - await write_encoded(conn, "\n[kub] ") + await write_encoded(conn, "\n[kub]\n") const user_message = make_message(name, line) const response_parts = await get_response_parts(history, user_message) let content = "", role = "assistant"