Skip to content

Commit

Permalink
1.0.24 (#28)
Browse files Browse the repository at this point in the history
* 1.0.24

* 1.0.24

* wip

* wip

* wip

* user settings

* Token counting

* moves

* Improved readonly views

* misc

* welcome page updates
  • Loading branch information
acharneski authored Nov 12, 2023
1 parent 3ed4d01 commit 6c66815
Show file tree
Hide file tree
Showing 83 changed files with 4,434 additions and 2,427 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ Maven:
<dependency>
<groupId>com.simiacryptus</groupId>
<artifactId>skyenet-webui</artifactId>
<version>1.0.23</version>
<version>1.0.24</version>
</dependency>
```

Gradle:

```groovy
implementation group: 'com.simiacryptus', name: 'skyenet', version: '1.0.23'
implementation group: 'com.simiacryptus', name: 'skyenet', version: '1.0.24'
```

```kotlin
implementation("com.simiacryptus:skyenet:1.0.23")
implementation("com.simiacryptus:skyenet:1.0.24")
```

### 🌟 To Use
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ val logback_version = "1.2.12"

dependencies {

implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.25")
implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.26")

implementation(group = "org.slf4j", name = "slf4j-api", version = "2.0.9")
implementation(group = "commons-io", name = "commons-io", version = "2.11.0")
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/kotlin/com/simiacryptus/skyenet/Ears.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import java.util.concurrent.atomic.AtomicInteger
/**
* The ears are the interface to the audio input for the SkyeNet system
*/
@Suppress("MemberVisibilityCanBePrivate", "unused")
@Suppress("unused")
open class Ears(
val api: OpenAIClient,
val secondsPerAudioPacket : Double = 0.25,
private val secondsPerAudioPacket : Double = 0.25,
) {

interface CommandRecognizer {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/kotlin/com/simiacryptus/skyenet/Heart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ interface Heart {
fun <T : Any> wrapExecution(fn: java.util.function.Supplier<T?>): T? = fn.get()

companion object {
@Suppress("unused")
private class TestObject {
@Suppress("unused")
fun square(x: Int): Int = x * x
}
private interface TestInterface {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/kotlin/com/simiacryptus/skyenet/Mouth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import javax.sound.sampled.SourceDataLine
/**
* The mouth is the interface to the Google Text-to-Speech API for the SkyeNet system
*/
@Suppress("MemberVisibilityCanBePrivate", "unused")
@Suppress("unused")
open class Mouth(
val keyfile: String
private val keyfile: String
) {

open fun speak(text: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ import com.simiacryptus.openai.OpenAIClient
abstract class BaseActor<T>(
open val prompt: String,
val name: String? = null,
val api: OpenAIClient = OpenAIClient(),
val model: OpenAIClient.Models = OpenAIClient.Models.GPT35Turbo,
val temperature: Double = 0.3,
) {

open fun response(vararg messages: OpenAIClient.ChatMessage, model: OpenAIClient.Models = this.model) = api.chat(
open fun response(vararg messages: OpenAIClient.ChatMessage, model: OpenAIClient.Models = this.model, api: OpenAIClient) = api.chat(
OpenAIClient.ChatRequest(
messages = messages.toList().toTypedArray(),
temperature = temperature,
model = this.model.modelName,
),
model = this.model
)
abstract fun answer(vararg messages: OpenAIClient.ChatMessage): T
open fun answer(vararg questions: String): T = answer(*chatMessages(*questions))
abstract fun answer(vararg messages: OpenAIClient.ChatMessage, api: OpenAIClient): T
open fun answer(vararg questions: String, api: OpenAIClient): T = answer(*chatMessages(*questions), api = api)

open fun chatMessages(vararg questions: String) = arrayOf(
OpenAIClient.ChatMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ class CodingActor(
),
name: String? = interpreterClass.simpleName,
val details: String? = null,
api: OpenAIClient = OpenAIClient(),
model: OpenAIClient.Models = OpenAIClient.Models.GPT35Turbo,
val fallbackModel: OpenAIClient.Models = OpenAIClient.Models.GPT4Turbo,
temperature: Double = 0.1,
) : BaseActor<CodeResult>(
prompt = "",
name = name,
api = api,
model = model,
temperature = temperature,
) {
Expand Down Expand Up @@ -89,22 +87,23 @@ class CodingActor(

open val interpreter by lazy { interpreterClass.java.getConstructor(Map::class.java).newInstance(symbols) }

override fun answer(vararg questions: String): CodeResult = answer(*chatMessages(*questions))
override fun answer(vararg questions: String, api: OpenAIClient): CodeResult = answer(*chatMessages(*questions), api = api)

override fun answer(vararg messages: OpenAIClient.ChatMessage): CodeResult {
return CodeResultImpl(*messages)
override fun answer(vararg messages: OpenAIClient.ChatMessage, api: OpenAIClient): CodeResult {
return CodeResultImpl(*messages, api = api)
}
fun answerWithPrefix(codePrefix: String, vararg messages: OpenAIClient.ChatMessage): CodeResult {
fun answerWithPrefix(codePrefix: String, vararg messages: OpenAIClient.ChatMessage, api: OpenAIClient): CodeResult {
val prevList = messages.toList()
val newList = prevList.dropLast(1) + listOf(
OpenAIClient.ChatMessage(OpenAIClient.ChatMessage.Role.assistant, codePrefix)
) + prevList.last()
return CodeResultImpl(*newList.toTypedArray())
return CodeResultImpl(*newList.toTypedArray(), api = api)
}

private inner class CodeResultImpl(
vararg messages: OpenAIClient.ChatMessage,
codePrefix: String = "",
api: OpenAIClient,
) : CodeResult {
var _status = CodeResult.Status.Coding
override fun getStatus(): CodeResult.Status {
Expand Down
22 changes: 10 additions & 12 deletions core/src/main/kotlin/com/simiacryptus/skyenet/actors/ParsedActor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,29 @@ class ParsedActor<T>(
val parserClass: Class<out Function<String, T>>,
prompt: String,
val action: String? = null,
api: OpenAIClient = OpenAIClient(),
model: OpenAIClient.Models = OpenAIClient.Models.GPT35Turbo,
temperature: Double = 0.3,
) : BaseActor<ParsedResponse<T>>(
api = api,
prompt = prompt,
name = action,
model = model,
temperature = temperature,
) {
private val parser: Function<String, T> = ChatProxy(
clazz = parserClass,
api = api,
model = OpenAIClient.Models.GPT35Turbo,
temperature = temperature,
).create()
private inner class ParsedResponseImpl(vararg messages: OpenAIClient.ChatMessage) : ParsedResponse<T> {
private val _text: String by lazy { response(*messages).choices.first().message?.content ?: throw RuntimeException("No response") }
private inner class ParsedResponseImpl(vararg messages: OpenAIClient.ChatMessage, api: OpenAIClient) : ParsedResponse<T> {
val parser: Function<String, T> = ChatProxy(
clazz = parserClass,
api = api,
model = OpenAIClient.Models.GPT35Turbo,
temperature = temperature,
).create()
private val _text: String by lazy { response(*messages, api = api).choices.first().message?.content ?: throw RuntimeException("No response") }
private val _obj: T by lazy { parser.apply(getText()) }
override fun getText(): String = _text
override fun getObj(): T = _obj
}

override fun answer(vararg messages: OpenAIClient.ChatMessage): ParsedResponse<T> {
return ParsedResponseImpl(*messages)
override fun answer(vararg messages: OpenAIClient.ChatMessage, api: OpenAIClient): ParsedResponse<T> {
return ParsedResponseImpl(*messages, api = api)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@ import com.simiacryptus.openai.OpenAIClient
class SimpleActor(
prompt: String,
name: String? = null,
api: OpenAIClient = OpenAIClient(),
model: OpenAIClient.Models = OpenAIClient.Models.GPT35Turbo,
temperature: Double = 0.3,
) : BaseActor<String>(
prompt = prompt,
name = name,
api = api,
model = model,
temperature = temperature,

) {

override fun answer(vararg questions: String): String = answer(*chatMessages(*questions))
override fun answer(vararg questions: String, api: OpenAIClient): String = answer(*chatMessages(*questions), api = api)

override fun answer(vararg messages: OpenAIClient.ChatMessage): String = response(*messages).choices.first().message?.content ?: throw RuntimeException("No response")
override fun answer(vararg messages: OpenAIClient.ChatMessage, api: OpenAIClient): String = response(*messages, api = api).choices.first().message?.content ?: throw RuntimeException("No response")
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.simiacryptus.skyenet
package com.simiacryptus.skyenet.util

import com.simiacryptus.skyenet.Heart
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object SessionServerUtil {
}
}

val logger = org.slf4j.LoggerFactory.getLogger(SessionServerUtil::class.java)
val log = org.slf4j.LoggerFactory.getLogger(SessionServerUtil::class.java)

fun getCode(language: String, textSegments: List<Pair<String, String>>) =
textSegments.joinToString("\n") {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gradle Releases -> https://github.com/gradle/gradle/releases
libraryGroup = com.simiacryptus.skyenet
libraryVersion = 1.0.23
libraryVersion = 1.0.24
gradleVersion = 7.6.1

# Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")

package com.simiacryptus.skyenet.heart.test

import com.simiacryptus.skyenet.HeartTestBase
import com.simiacryptus.skyenet.util.HeartTestBase
import com.simiacryptus.skyenet.heart.GroovyInterpreter
import org.junit.jupiter.api.Test

class GroovyInterpreterTest : HeartTestBase() {
override fun newInterpreter(map: java.util.Map<String,Object>) = GroovyInterpreter(map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ open class KotlinInterpreter(
}
}

val scriptEngineFactory = object : KotlinJsr223JvmScriptEngineFactoryBase() {
private val scriptEngineFactory = object : KotlinJsr223JvmScriptEngineFactoryBase() {
override fun getScriptEngine(): ScriptEngine {
return KotlinJsr223ScriptEngineImpl(
this,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")

package com.simiacryptus.skyenet.heart

import com.simiacryptus.skyenet.HeartTestBase
import com.simiacryptus.skyenet.util.HeartTestBase
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import java.util.Map

class KotlinInterpreterTest : HeartTestBase() {

override fun newInterpreter(map: java.util.Map<String, Object>) = KotlinInterpreter(map)
override fun newInterpreter(map: Map<String, Object>) = KotlinInterpreter(map)

@Test
override fun `test run with variables`() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.test

import com.simiacryptus.skyenet.heart.ScalaLocalInterpreter
import com.simiacryptus.skyenet.{Heart, HeartTestBase}
import com.simiacryptus.skyenet.Heart
import com.simiacryptus.skyenet.util.HeartTestBase

import java.util

Expand Down
2 changes: 1 addition & 1 deletion webui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.25")
implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.26")

implementation(project(":core"))
testImplementation(project(":groovy"))
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6c66815

Please sign in to comment.