From 273767692805012d1f8396180664f8210eb78cae Mon Sep 17 00:00:00 2001 From: Andrew Charneski Date: Sun, 12 Nov 2023 03:01:18 -0500 Subject: [PATCH] 1.0.25 (#29) --- README.md | 6 +++--- core/build.gradle.kts | 2 +- gradle.properties | 2 +- webui/build.gradle.kts | 2 +- .../skyenet/servers/ReadOnlyApp.kt | 19 +++++++++++++++++-- .../skyenet/sessions/MessageWebSocket.kt | 2 +- .../skyenet/sessions/WebSocketServer.kt | 11 ++++++++--- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 11f71762..6d0189e9 100644 --- a/README.md +++ b/README.md @@ -76,18 +76,18 @@ Maven: com.simiacryptus skyenet-webui - 1.0.24 + 1.0.25 ``` Gradle: ```groovy -implementation group: 'com.simiacryptus', name: 'skyenet', version: '1.0.24' +implementation group: 'com.simiacryptus', name: 'skyenet', version: '1.0.25' ``` ```kotlin -implementation("com.simiacryptus:skyenet:1.0.24") +implementation("com.simiacryptus:skyenet:1.0.25") ``` ### 🌟 To Use diff --git a/core/build.gradle.kts b/core/build.gradle.kts index a9071613..d3b1c28f 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -33,7 +33,7 @@ val logback_version = "1.2.12" dependencies { - implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.26") + implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.27") implementation(group = "org.slf4j", name = "slf4j-api", version = "2.0.9") implementation(group = "commons-io", name = "commons-io", version = "2.11.0") diff --git a/gradle.properties b/gradle.properties index cb87d5b5..a3bccd4b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Gradle Releases -> https://github.com/gradle/gradle/releases libraryGroup = com.simiacryptus.skyenet -libraryVersion = 1.0.24 +libraryVersion = 1.0.25 gradleVersion = 7.6.1 # Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library diff --git a/webui/build.gradle.kts b/webui/build.gradle.kts index 79c3c9b2..69b5b317 100644 --- a/webui/build.gradle.kts +++ b/webui/build.gradle.kts @@ -32,7 +32,7 @@ val jetty_version = "11.0.17" val jackson_version = "2.15.2" dependencies { - implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.26") + implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.27") implementation(project(":core")) testImplementation(project(":groovy")) diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/servers/ReadOnlyApp.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/servers/ReadOnlyApp.kt index 09898679..40c0ee8b 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/servers/ReadOnlyApp.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/servers/ReadOnlyApp.kt @@ -2,6 +2,7 @@ package com.simiacryptus.skyenet.servers import com.simiacryptus.skyenet.sessions.* import org.slf4j.LoggerFactory +import java.io.File open class ReadOnlyApp( applicationName: String, @@ -18,8 +19,22 @@ open class ReadOnlyApp( val log = LoggerFactory.getLogger(ReadOnlyApp::class.java) } - override fun newSession(sessionId: String): SessionInterface { - throw UnsupportedOperationException() + override fun newSession(sessionId: String): SessionInterface = object : SessionInterface { + override fun removeSocket(socket: MessageWebSocket) { + // Do nothing + } + + override fun addSocket(socket: MessageWebSocket) { + // Do nothing + } + + override fun getReplay(): List { + return SessionDataStorage(File(File(".skynet"), applicationName)).loadMessages(sessionId).values.toList() + } + + override fun onWebSocketText(socket: MessageWebSocket, message: String) { + // Do nothing + } } diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/sessions/MessageWebSocket.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/sessions/MessageWebSocket.kt index 93cb3888..6868fa4d 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/sessions/MessageWebSocket.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/sessions/MessageWebSocket.kt @@ -40,7 +40,7 @@ class MessageWebSocket( ) ) { override fun incrementTokens(model: Model?, tokens: Int) { - incrementUsage(sessionId, userinfo, model!!, tokens) + if(null != model) incrementUsage(sessionId, userinfo, model, tokens) super.incrementTokens(model, tokens) } } diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/sessions/WebSocketServer.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/sessions/WebSocketServer.kt index 2d80f053..263daa3e 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/sessions/WebSocketServer.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/sessions/WebSocketServer.kt @@ -23,9 +23,14 @@ abstract class WebSocketServer(val resourceBase: String) { return@setCreator if (null == sessionId) { null } else { - MessageWebSocket(sessionId, stateCache.getOrPut(sessionId) { - newSession(sessionId) - }, authId, sessionDataStorage) + val sessionState: SessionInterface + if (stateCache.containsKey(sessionId)) { + sessionState = stateCache[sessionId]!! + } else { + sessionState = newSession(sessionId) + if(null != sessionState) stateCache[sessionId] = sessionState + } + MessageWebSocket(sessionId, sessionState, authId, sessionDataStorage) } } }