From 3ec61dcfe61560ba8491a3287266112853a34e55 Mon Sep 17 00:00:00 2001 From: Andrew Charneski Date: Fri, 24 Nov 2023 16:50:07 -0500 Subject: [PATCH] misc --- core/build.gradle.kts | 2 +- .../skyenet/core/actors/CodingActor.kt | 96 +++++++++++++++---- .../skyenet/core/actors/ParsedActor.kt | 5 +- .../actors/record/CodingActorInterceptor.kt | 5 +- .../actors/record/ParsedActorInterceptor.kt | 3 +- .../skyenet/core/actors/test/ActorTestBase.kt | 7 +- webui/build.gradle.kts | 2 +- .../webui/application/ApplicationInterface.kt | 15 ++- .../webui/application/ApplicationServer.kt | 1 - .../application/ApplicationSocketManager.kt | 4 +- .../skyenet/webui/chat/ChatSocketManager.kt | 4 +- .../{SessionMessage.kt => SessionTask.kt} | 6 +- .../webui/session/SocketManagerBase.kt | 18 ++-- .../skyenet/webui/test/CodingActorTestApp.kt | 6 +- .../skyenet/webui/test/ImageActorTestApp.kt | 2 +- .../skyenet/webui/test/ParsedActorTestApp.kt | 2 +- .../skyenet/webui/test/SimpleActorTestApp.kt | 2 +- 17 files changed, 118 insertions(+), 62 deletions(-) rename webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/{SessionMessage.kt => SessionTask.kt} (94%) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 8e980685..9747e9c9 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -31,7 +31,7 @@ val logback_version = "1.4.11" dependencies { - implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.35") + implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.36") implementation(group = "org.slf4j", name = "slf4j-api", version = "2.0.9") implementation(group = "commons-io", name = "commons-io", version = "2.15.0") diff --git a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/CodingActor.kt b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/CodingActor.kt index 2abfcdd0..7cdd4ae1 100644 --- a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/CodingActor.kt +++ b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/CodingActor.kt @@ -10,6 +10,7 @@ import com.simiacryptus.jopenai.describe.TypeDescriber import com.simiacryptus.jopenai.models.ChatModels import com.simiacryptus.skyenet.core.Interpreter import com.simiacryptus.skyenet.core.OutputInterceptor +import java.util.* import javax.script.ScriptException import kotlin.reflect.KClass @@ -28,6 +29,7 @@ open class CodingActor( val autoEvaluate: Boolean = false, private val fixIterations: Int = 3, private val fixRetries: Int = 2, + val runtimeSymbols: Map = mapOf() ) : BaseActor( prompt = "", name = name, @@ -52,19 +54,21 @@ open class CodingActor( override val prompt: String get() = if (symbols.isNotEmpty()) """ |You will translate natural language instructions into - |an implementation using ${interpreter.getLanguage()} and the script context. - |Use ``` code blocks labeled with ${interpreter.getLanguage()} where appropriate. - |Defined symbols include ${symbols.keys.joinToString(", ")}. - |The runtime context is described below: + |an implementation using ${language} and the script context. + |Use ``` code blocks labeled with ${language} where appropriate. | + |Defined symbols include {${symbols.keys.joinToString(", ")}} described below: + | + |```${this.describer.markupLanguage} |${this.apiDescription} + |``` | |${details ?: ""} |""".trimMargin().trim() else """ |You will translate natural language instructions into - |an implementation using ${interpreter.getLanguage()} and the script context. - |Use ``` code blocks labeled with ${interpreter.getLanguage()} where appropriate. + |an implementation using ${language} and the script context. + |Use ``` code blocks labeled with ${language} where appropriate. | |${details ?: ""} |""".trimMargin().trim() @@ -77,9 +81,9 @@ open class CodingActor( |""".trimMargin().trim() }.joinToString("\n") - open val interpreter: Interpreter by lazy { interpreterClass.java.getConstructor(Map::class.java).newInstance(symbols) } + open val interpreter: Interpreter by lazy { interpreterClass.java.getConstructor(Map::class.java).newInstance(symbols + runtimeSymbols) } - protected val language: String by lazy { interpreter.getLanguage() } + val language: String by lazy { interpreter.getLanguage() } override fun answer(vararg questions: String, api: API): CodeResult = if (!autoEvaluate) answer(*chatMessages(*questions), api = api) @@ -95,7 +99,7 @@ open class CodingActor( api: API ): CodeResult = if (!autoEvaluate) CodeResultImpl(*injectCodePrefix(messages, codePrefix), api = (api as OpenAIClient)) - else answerWithAutoEval(*injectCodePrefix(messages, codePrefix), api = api).first + else answerWithAutoEval(*injectCodePrefix(messages, codePrefix), api = api, codePrefix=codePrefix).first open fun answerWithAutoEval( vararg messages: String, @@ -105,9 +109,10 @@ open class CodingActor( open fun answerWithAutoEval( vararg messages: ChatMessage, - api: API + api: API, + codePrefix: String = "" ): Pair { - var result = CodeResultImpl(*messages, api = (api as OpenAIClient)) + var result = CodeResultImpl(*messages, api = (api as OpenAIClient), codePrefix = codePrefix) var lastError: Throwable? = null for (i in 0..fixIterations) try { return result to result.run() @@ -116,7 +121,7 @@ open class CodingActor( result = run { val respondWithCode = fixCommand(api, result.getCode(), ex, *messages, model = model) val renderedResponse = getRenderedResponse(respondWithCode.second) - val codedInstruction = getCode(interpreter.getLanguage(), respondWithCode.second) + val codedInstruction = getCode(language, respondWithCode.second) log.info("Response: \n\t${renderedResponse.replace("\n", "\n\t", false)}".trimMargin()) log.info("Code: \n\t${codedInstruction.replace("\n", "\n\t", false)}".trimMargin()) CodeResultImpl(*messages, codePrefix = codedInstruction, api = api) @@ -125,7 +130,7 @@ open class CodingActor( throw RuntimeException( """ |Failed to fix code. Last attempt: - |```${interpreter.getLanguage().lowercase()} + |```${language.lowercase()} |${result.getCode()} |``` | @@ -150,7 +155,7 @@ open class CodingActor( val codeBlocks = extractCodeBlocks(response) for (codingAttempt in 0..fixRetries) { val renderedResponse = getRenderedResponse(codeBlocks) - val codedInstruction = getCode(interpreter.getLanguage(), codeBlocks) + val codedInstruction = getCode(language, codeBlocks) log.info("Response: \n\t${renderedResponse.replace("\n", "\n\t", false)}".trimMargin()) log.info("Code: \n\t${codedInstruction.replace("\n", "\n\t", false)}".trimMargin()) return validateAndFix(self, codedInstruction, codePrefix, api, messages, model) ?: continue @@ -169,7 +174,7 @@ open class CodingActor( var workingCode = initialCode for (fixAttempt in 0..fixIterations) { try { - val validate = interpreter.validate((codePrefix + "\n" + workingCode).trim()) + val validate = interpreter.validate((codePrefix + "\n" + workingCode).sortCode()) if (validate != null) throw validate log.info("Validation succeeded") (self as CodeResultImpl)._status = CodeResult.Status.Success @@ -179,7 +184,7 @@ open class CodingActor( (self as CodeResultImpl)._status = CodeResult.Status.Correcting val respondWithCode = fixCommand(api, workingCode, ex, *messages, model = model) val response = getRenderedResponse(respondWithCode.second) - workingCode = getCode(interpreter.getLanguage(), respondWithCode.second) + workingCode = getCode(language, respondWithCode.second) log.info("Response: \n\t${response.replace("\n", "\n\t", false)}".trimMargin()) log.info("Code: \n\t${workingCode.replace("\n", "\n\t", false)}".trimMargin()) } @@ -211,7 +216,7 @@ open class CodingActor( private inner class CodeResultImpl( vararg messages: ChatMessage, - codePrefix: String = "", + val codePrefix: String = "", api: OpenAIClient, ) : CodeResult { var _status = CodeResult.Status.Coding @@ -238,7 +243,7 @@ open class CodingActor( @JsonIgnore override fun getCode(): String = impl - override fun run() = execute(getCode()) + override fun run() = execute(codePrefix + "\n" + getCode().sortCode()) } private fun injectCodePrefix( @@ -363,6 +368,61 @@ open class CodingActor( } } + fun String.sortCode(bodyWrapper: (String) -> String = { it }): String { + val (imports, otherCode) = this.split("\n").partition { it.trim().startsWith("import ") } + return imports.distinct().sorted().joinToString("\n") + "\n\n" + bodyWrapper(otherCode.joinToString("\n")) + } + + fun String.camelCase(locale: Locale = Locale.getDefault()): String { + val words = fromPascalCase().split(" ").map { it.trim() }.filter { it.isNotEmpty() } + return words.first().lowercase(locale) + words.drop(1).joinToString("") { + it.replaceFirstChar { c -> + when { + c.isLowerCase() -> c.titlecase(locale) + else -> c.toString() + } + } + } + } + + fun String.pascalCase(locale: Locale = Locale.getDefault()): String = + fromPascalCase().split(" ").map { it.trim() }.filter { it.isNotEmpty() }.joinToString("") { + it.replaceFirstChar { c -> + when { + c.isLowerCase() -> c.titlecase(locale) + else -> c.toString() + } + } + } + + // Detect changes in the case of the first letter and prepend a space + fun String.fromPascalCase(): String = buildString { + var lastChar = ' ' + for (c in this@fromPascalCase) { + if (c.isUpperCase() && lastChar.isLowerCase()) append(' ') + append(c) + lastChar = c + } + } + + fun String.upperSnakeCase(locale: Locale = Locale.getDefault()): String = + fromPascalCase().split(" ").map { it.trim() }.filter { it.isNotEmpty() }.joinToString("_") { + it.replaceFirstChar { c -> + when { + c.isLowerCase() -> c.titlecase(locale) + else -> c.toString() + } + } + }.uppercase(locale) + + fun String.imports(): List { + return this.split("\n").filter { it.trim().startsWith("import ") }.distinct().sorted() + } + + fun String.stripImports(): String { + return this.split("\n").filter { !it.trim().startsWith("import ") }.joinToString("\n") + } + } } diff --git a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/ParsedActor.kt b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/ParsedActor.kt index f0a94aa3..ca4b5118 100644 --- a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/ParsedActor.kt +++ b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/ParsedActor.kt @@ -3,19 +3,18 @@ package com.simiacryptus.skyenet.core.actors import com.simiacryptus.jopenai.API import com.simiacryptus.jopenai.OpenAIClient import com.simiacryptus.jopenai.models.ChatModels -import com.simiacryptus.jopenai.models.OpenAITextModel import com.simiacryptus.jopenai.proxy.ChatProxy import java.util.function.Function open class ParsedActor( val parserClass: Class>, prompt: String, - val action: String? = null, + name: String? = parserClass.simpleName, model: ChatModels = ChatModels.GPT35Turbo, temperature: Double = 0.3, ) : BaseActor>( prompt = prompt, - name = action, + name = name, model = model, temperature = temperature, ) { diff --git a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/record/CodingActorInterceptor.kt b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/record/CodingActorInterceptor.kt index bc942f4f..45d5c497 100644 --- a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/record/CodingActorInterceptor.kt +++ b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/record/CodingActorInterceptor.kt @@ -70,9 +70,10 @@ class CodingActorInterceptor( override fun answerWithAutoEval( vararg messages: ChatMessage, - api: API + api: API, + codePrefix: String, ) = functionInterceptor.wrap(messages.toList().toTypedArray()) { - inner.answerWithAutoEval(*messages, api = api) + inner.answerWithAutoEval(*messages, api = api, codePrefix = codePrefix) } override fun implement( diff --git a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/record/ParsedActorInterceptor.kt b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/record/ParsedActorInterceptor.kt index 0d68df6b..868e06bf 100644 --- a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/record/ParsedActorInterceptor.kt +++ b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/record/ParsedActorInterceptor.kt @@ -3,7 +3,6 @@ package com.simiacryptus.skyenet.core.actors.record import com.simiacryptus.jopenai.API import com.simiacryptus.jopenai.models.OpenAIModel import com.simiacryptus.skyenet.core.actors.ParsedActor -import com.simiacryptus.skyenet.core.actors.ParsedResponse import com.simiacryptus.skyenet.core.util.FunctionWrapper class ParsedActorInterceptor( @@ -12,7 +11,7 @@ class ParsedActorInterceptor( ) : ParsedActor( parserClass = inner.parserClass, prompt = inner.prompt, - action = inner.action, + name = inner.name, model = inner.model, temperature = inner.temperature, ) { diff --git a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/test/ActorTestBase.kt b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/test/ActorTestBase.kt index 20d7903d..5cdf3073 100644 --- a/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/test/ActorTestBase.kt +++ b/core/src/main/kotlin/com/simiacryptus/skyenet/core/actors/test/ActorTestBase.kt @@ -45,16 +45,19 @@ abstract class ActorTestBase { open fun testRun() { testCases.forEach { testCase -> - val answer = actor.answer(messages = arrayOf( + val messages = arrayOf( ApiModel.ChatMessage( role = com.simiacryptus.jopenai.ApiModel.Role.system, content = actor.prompt.toContentList() ), - ) + testCase.userMessages.toTypedArray(), api) + ) + testCase.userMessages.toTypedArray() + val answer = answer(messages) log.info("Answer: ${resultMapper(answer)}") } } + open fun answer(messages: Array): R = actor.answer(messages = messages, api) + companion object { private val log = LoggerFactory.getLogger(ActorTestBase::class.java) } diff --git a/webui/build.gradle.kts b/webui/build.gradle.kts index e4573dab..d46a9a51 100644 --- a/webui/build.gradle.kts +++ b/webui/build.gradle.kts @@ -32,7 +32,7 @@ val jetty_version = "11.0.18" val jackson_version = "2.15.3" dependencies { - implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.35") + implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.36") implementation(project(":core")) testImplementation(project(":groovy")) diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationInterface.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationInterface.kt index f2c47d0a..bc90d38b 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationInterface.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationInterface.kt @@ -1,21 +1,20 @@ package com.simiacryptus.skyenet.webui.application -import com.simiacryptus.skyenet.webui.session.SessionMessage -import com.simiacryptus.skyenet.webui.session.SocketManagerBase +import com.simiacryptus.jopenai.describe.Description +import com.simiacryptus.skyenet.webui.session.SessionTask import java.util.function.Consumer class ApplicationInterface(private val inner: ApplicationSocketManager) { - fun send(html: String) = inner.send(html) + @Description("Returns html for a link that will trigger the given handler when clicked.") fun hrefLink(linkText: String, classname: String = """href-link""", handler: Consumer) = inner.hrefLink(linkText, classname, handler) + @Description("Returns html for a text input form that will trigger the given handler when submitted.") fun textInput(handler: Consumer): String = inner.textInput(handler) - fun newMessage( - operationID: String = SocketManagerBase.randomID(), - spinner: String = SessionMessage.spinner, - cancelable: Boolean = false - ): SessionMessage = inner.newMessage(operationID, spinner, cancelable) + fun newTask( + //cancelable: Boolean = false + ): SessionTask = inner.newTask(false) } \ No newline at end of file diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationServer.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationServer.kt index 8d6fb34b..757e824a 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationServer.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationServer.kt @@ -11,7 +11,6 @@ import com.simiacryptus.skyenet.core.platform.Session import com.simiacryptus.skyenet.core.platform.User import com.simiacryptus.skyenet.webui.chat.ChatServer import com.simiacryptus.skyenet.webui.servlet.* -import com.simiacryptus.skyenet.webui.session.SessionMessage import com.simiacryptus.skyenet.webui.session.SocketManager import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationSocketManager.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationSocketManager.kt index 6bf3ca28..a69c48a8 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationSocketManager.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationSocketManager.kt @@ -6,7 +6,7 @@ import com.simiacryptus.skyenet.core.platform.DataStorage import com.simiacryptus.skyenet.core.platform.Session import com.simiacryptus.skyenet.core.platform.User import com.simiacryptus.skyenet.webui.chat.ChatSocket -import com.simiacryptus.skyenet.webui.session.SessionMessage +import com.simiacryptus.skyenet.webui.session.SessionTask import com.simiacryptus.skyenet.webui.session.SocketManagerBase import java.util.function.Consumer @@ -80,7 +80,7 @@ abstract class ApplicationSocketManager( ) companion object { - val spinner: String get() = """
${SessionMessage.spinner}
""" + val spinner: String get() = """
${SessionTask.spinner}
""" // val playButton: String get() = """""" // val cancelButton: String get() = """""" // val regenButton: String get() = """""" diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/chat/ChatSocketManager.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/chat/ChatSocketManager.kt index 3a5c2da0..1a86ba3a 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/chat/ChatSocketManager.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/chat/ChatSocketManager.kt @@ -7,7 +7,7 @@ import com.simiacryptus.jopenai.models.ChatModels import com.simiacryptus.jopenai.models.OpenAITextModel import com.simiacryptus.skyenet.core.platform.Session import com.simiacryptus.skyenet.webui.application.ApplicationServer -import com.simiacryptus.skyenet.webui.session.SessionMessage +import com.simiacryptus.skyenet.webui.session.SessionTask import com.simiacryptus.skyenet.webui.session.SocketManagerBase import com.simiacryptus.skyenet.webui.util.MarkdownUtil @@ -42,7 +42,7 @@ open class ChatSocketManager( override fun onRun(userMessage: String, socket: ChatSocket) { var responseContents = divInitializer(cancelable = false) responseContents += """
${renderResponse(userMessage)}
""" - send("""$responseContents
${SessionMessage.spinner}
""") + send("""$responseContents
${SessionTask.spinner}
""") messages += ApiModel.ChatMessage(ApiModel.Role.user, userMessage.toContentList()) try { val response = api.chat( diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SessionMessage.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SessionTask.kt similarity index 94% rename from webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SessionMessage.kt rename to webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SessionTask.kt index cf67186e..2605388e 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SessionMessage.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SessionTask.kt @@ -5,9 +5,9 @@ import org.slf4j.LoggerFactory import java.awt.image.BufferedImage import java.util.* -abstract class SessionMessage( +abstract class SessionTask( private var buffer: MutableList = mutableListOf(), - private val spinner: String = SessionMessage.spinner + private val spinner: String = SessionTask.spinner ) { val currentText: String get() = buffer.filter { it.isNotBlank() }.joinToString("") @@ -62,7 +62,7 @@ abstract class SessionMessage( add("""""") companion object { - val log = LoggerFactory.getLogger(SessionMessage::class.java) + val log = LoggerFactory.getLogger(SessionTask::class.java) const val spinner = """
Loading...
""" diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SocketManagerBase.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SocketManagerBase.kt index ae993b3e..b590cc42 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SocketManagerBase.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/session/SocketManagerBase.kt @@ -6,10 +6,8 @@ import com.simiacryptus.skyenet.webui.chat.ChatServer import com.simiacryptus.skyenet.webui.chat.ChatSocket import com.simiacryptus.skyenet.webui.util.MarkdownUtil import org.slf4j.LoggerFactory -import java.net.URL import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicInteger -import kotlin.io.path.Path abstract class SocketManagerBase( protected val session: Session, @@ -45,20 +43,18 @@ abstract class SocketManagerBase( } } - fun newMessage( - operationID: String = randomID(), - spinner: String = SessionMessage.spinner, + fun newTask( cancelable: Boolean = false - ): SessionMessage { - var responseContents = divInitializer(operationID, cancelable) + ): SessionTask { + var responseContents = divInitializer(randomID(), cancelable) send(responseContents) - return SessionMessageImpl(responseContents, spinner) + return SessionTaskImpl(responseContents, SessionTask.spinner) } - inner class SessionMessageImpl( + inner class SessionTaskImpl( responseContents: String, - spinner: String = SessionMessage.spinner - ) : SessionMessage(mutableListOf(StringBuilder(responseContents)), spinner) { + spinner: String = SessionTask.spinner + ) : SessionTask(mutableListOf(StringBuilder(responseContents)), spinner) { override fun send(html: String) = this@SocketManagerBase.send(html) override fun save(file: String, data: ByteArray): String { dataStorage?.getSessionDir(user, session)?.let { dir -> diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/CodingActorTestApp.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/CodingActorTestApp.kt index ac627f16..e9c633f6 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/CodingActorTestApp.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/CodingActorTestApp.kt @@ -14,7 +14,7 @@ import java.util.* open class CodingActorTestApp( private val actor: CodingActor, - applicationName: String = "CodingActorTest_" + actor.interpreter.javaClass.simpleName, + applicationName: String = "CodingActorTest_" + actor.name, temperature: Double = 0.3, ) : ApplicationServer( applicationName = applicationName, @@ -27,7 +27,7 @@ open class CodingActorTestApp( ui: ApplicationInterface, api: API ) { - val message = ui.newMessage() + val message = ui.newTask() try { message.echo(renderMarkdown(userMessage)) val response = actor.answer(userMessage, api = api) @@ -51,7 +51,7 @@ open class CodingActorTestApp( message.complete( renderMarkdown( """ - |```${actor.interpreter.getLanguage().lowercase(Locale.getDefault())} + |```${actor.language.lowercase(Locale.getDefault())} |${response.getCode()} |``` |$playLink diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/ImageActorTestApp.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/ImageActorTestApp.kt index ffdeb2eb..60be2062 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/ImageActorTestApp.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/ImageActorTestApp.kt @@ -31,7 +31,7 @@ open class ImageActorTestApp( ui: ApplicationInterface, api: API ) { - val message = ui.newMessage() + val message = ui.newTask() try { val actor = getSettings(session, user)?.actor ?: actor message.echo(renderMarkdown(userMessage)) diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/ParsedActorTestApp.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/ParsedActorTestApp.kt index 1d0501df..16651af2 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/ParsedActorTestApp.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/ParsedActorTestApp.kt @@ -25,7 +25,7 @@ open class ParsedActorTestApp( ui: ApplicationInterface, api: API ) { - val message = ui.newMessage() + val message = ui.newTask() try { message.echo(renderMarkdown(userMessage)) val response = actor.answer(userMessage, api = api) diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/SimpleActorTestApp.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/SimpleActorTestApp.kt index 03df505b..9e6fda25 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/SimpleActorTestApp.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/test/SimpleActorTestApp.kt @@ -31,7 +31,7 @@ open class SimpleActorTestApp( ui: ApplicationInterface, api: API ) { - val message = ui.newMessage() + val message = ui.newTask() try { val actor = getSettings(session, user)?.actor ?: actor message.echo(renderMarkdown(userMessage))