Improve logging.

This commit is contained in:
JOLIMAITRE Matthieu 2025-05-28 19:02:59 +02:00
parent ba61f6b0cf
commit 0172b20207
2 changed files with 4 additions and 2 deletions

View file

@ -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

View file

@ -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"