From 1d3714266a2d789b2fec182b2a6a7d7c3b3b473f Mon Sep 17 00:00:00 2001 From: Andrew Charneski Date: Tue, 21 Nov 2023 02:47:31 -0500 Subject: [PATCH] Update ChatSocket.kt --- .../kotlin/com/simiacryptus/skyenet/chat/ChatSocket.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/chat/ChatSocket.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/chat/ChatSocket.kt index 6b788f45..34d5878e 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/chat/ChatSocket.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/chat/ChatSocket.kt @@ -17,7 +17,11 @@ class ChatSocket( private val user: User?, ) : WebSocketAdapter() { - private val logfile = ".sys/openai.log" + val logfile by lazy { + val file = dataStorage?.getSessionDir(user, session)?.resolve(".sys/openai.log") + file?.parentFile?.mkdirs() + file + } val api: OpenAIClient get() { @@ -29,7 +33,7 @@ class ChatSocket( return object : OpenAIClient( logLevel = Level.DEBUG, logStreams = mutableListOf( - dataStorage?.getSessionDir(user, session)?.resolve(logfile)?.outputStream()?.buffered() + logfile?.outputStream()?.buffered() ).filterNotNull().toMutableList() ) { override fun incrementTokens(model: OpenAIModel?, tokens: Usage) { @@ -48,7 +52,7 @@ class ChatSocket( key = userSettings.apiKey, logLevel = Level.DEBUG, logStreams = mutableListOf( - dataStorage?.getSessionDir(user, session)?.resolve(logfile)?.outputStream()?.buffered() + logfile?.outputStream()?.buffered() ).filterNotNull().toMutableList(), ) { override fun incrementTokens(model: OpenAIModel?, tokens: Usage) {