Skip to content

Commit

Permalink
1.2.11 (#112)
Browse files Browse the repository at this point in the history
* fix

* refactor

* 1.2.11

* fix

* fix

* fix
  • Loading branch information
acharneski authored Oct 18, 2024
1 parent d3ad897 commit c135230
Show file tree
Hide file tree
Showing 150 changed files with 5,939 additions and 5,736 deletions.
3 changes: 1 addition & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ val hsqldb_version = "2.7.2"

dependencies {

implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.1.9")
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.1.10")
implementation(group = "org.hsqldb", name = "hsqldb", version = hsqldb_version)

implementation("org.apache.commons:commons-text:1.11.0")
Expand Down Expand Up @@ -103,7 +103,6 @@ tasks {
}



val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.javadoc)
Expand Down
1,704 changes: 740 additions & 964 deletions core/src/main/dev_documentation.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.simiacryptus.skyenet.core.actors

import com.simiacryptus.skyenet.core.platform.ApplicationServices
import com.simiacryptus.skyenet.core.platform.Session
import com.simiacryptus.skyenet.core.platform.StorageInterface
import com.simiacryptus.skyenet.core.platform.User
import com.simiacryptus.skyenet.core.platform.model.StorageInterface
import com.simiacryptus.skyenet.core.platform.model.User

open class ActorSystem<T : Enum<*>>(
val actors: Map<String, BaseActor<*, *>>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.simiacryptus.skyenet.core.actors

import com.simiacryptus.jopenai.API
import com.simiacryptus.jopenai.models.ApiModel
import com.simiacryptus.jopenai.ChatClient
import com.simiacryptus.jopenai.OpenAIClient
import com.simiacryptus.jopenai.models.ChatModels
import com.simiacryptus.jopenai.models.ApiModel
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.jopenai.models.OpenAIModel
import com.simiacryptus.jopenai.models.OpenAITextModel
import com.simiacryptus.jopenai.models.TextModel

abstract class BaseActor<I, R>(
open val prompt: String,
val name: String? = null,
val model: OpenAITextModel,
val model: TextModel,
val temperature: Double = 0.3,
) {
abstract fun respond(input: I, api: API, vararg messages: ApiModel.ChatMessage): R
Expand All @@ -28,5 +27,5 @@ abstract class BaseActor<I, R>(
open fun answer(input: I, api: API): R = respond(input = input, api = api, *chatMessages(input))

abstract fun chatMessages(questions: I): Array<ApiModel.ChatMessage>
abstract fun withModel(model: ChatModels): BaseActor<I, R>
abstract fun withModel(model: ChatModel): BaseActor<I, R>
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package com.simiacryptus.skyenet.core.actors

import com.simiacryptus.jopenai.API
import com.simiacryptus.jopenai.models.ApiModel.*
import com.simiacryptus.jopenai.ChatClient
import com.simiacryptus.jopenai.describe.AbbrevWhitelistTSDescriber
import com.simiacryptus.jopenai.describe.AbbrevWhitelistYamlDescriber
import com.simiacryptus.jopenai.describe.TypeDescriber
import com.simiacryptus.jopenai.models.ChatModels
import com.simiacryptus.jopenai.models.ApiModel.*
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.jopenai.models.OpenAIModels
import com.simiacryptus.jopenai.models.OpenAITextModel
import com.simiacryptus.jopenai.models.TextModel
import com.simiacryptus.jopenai.util.ClientUtil.toContentList
import com.simiacryptus.skyenet.core.OutputInterceptor
import com.simiacryptus.skyenet.interpreter.Interpreter
import java.util.*
import javax.script.ScriptException
import kotlin.reflect.KClass

private const val TT = "`"+"`"+"`"
private const val TT = "`" + "`" + "`"
typealias CodeInterceptor = (String) -> String


Expand All @@ -29,8 +28,8 @@ open class CodingActor(
),
name: String? = interpreterClass.simpleName,
val details: String? = null,
model: OpenAITextModel = OpenAIModels.GPT4o,
val fallbackModel: ChatModels = OpenAIModels.GPT4o,
model: TextModel = OpenAIModels.GPT4o,
val fallbackModel: ChatModel = OpenAIModels.GPT4o,
temperature: Double = 0.1,
val runtimeSymbols: Map<String, Any> = mapOf(),
var codeInterceptor: CodeInterceptor = { it }
Expand Down Expand Up @@ -92,7 +91,7 @@ They are already defined for you.
${details ?: ""}
""".trim()
} else """
} else """
You are a coding assistant allowing users actions to be enacted using $language and the script context.
Your role is to translate natural language instructions into code as well as interpret the results and converse with the user.
Use $TT code blocks labeled with $language where appropriate. (i.e. ${TT}$language)
Expand Down Expand Up @@ -247,7 +246,7 @@ ${details ?: ""}
override val code: String = givenCode ?: implementation.first

private fun implement(
model: OpenAITextModel,
model: TextModel,
): Pair<String, String> {
val request = ChatRequest(messages = ArrayList(this.messages.toList()))
for (codingAttempt in 0..input.fixRetries) {
Expand Down Expand Up @@ -322,7 +321,7 @@ ${TT}
previousCode: String,
error: Throwable,
vararg promptMessages: ChatMessage,
model: OpenAITextModel
model: TextModel
): String = chat(
api = api,
request = ChatRequest(
Expand Down Expand Up @@ -354,12 +353,12 @@ Correct the code and try again.
model = model
)

private fun chat(api: ChatClient, request: ChatRequest, model: OpenAITextModel) =
private fun chat(api: ChatClient, request: ChatRequest, model: TextModel) =
api.chat(request.copy(model = model.modelName, temperature = temperature), model)
.choices.first().message?.content.orEmpty().trim()


override fun withModel(model: ChatModels): CodingActor = CodingActor(
override fun withModel(model: ChatModel): CodingActor = CodingActor(
interpreterClass = interpreterClass,
symbols = symbols,
describer = describer,
Expand All @@ -368,7 +367,7 @@ Correct the code and try again.
model = model,
fallbackModel = fallbackModel,
temperature = temperature,
runtimeSymbols = runtimeSymbols,
runtimeSymbols = runtimeSymbols,
codeInterceptor = codeInterceptor
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.simiacryptus.skyenet.core.actors

import com.simiacryptus.jopenai.API
import com.simiacryptus.jopenai.OpenAIClient
import com.simiacryptus.jopenai.models.ApiModel
import com.simiacryptus.jopenai.models.ApiModel.ChatMessage
import com.simiacryptus.jopenai.models.ApiModel.ImageGenerationRequest
import com.simiacryptus.jopenai.OpenAIClient
import com.simiacryptus.jopenai.models.ChatModels
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.jopenai.models.ImageModels
import com.simiacryptus.jopenai.models.OpenAITextModel
import com.simiacryptus.jopenai.models.TextModel
import com.simiacryptus.jopenai.util.ClientUtil.toChatMessage
import com.simiacryptus.jopenai.util.ClientUtil.toContentList
import java.awt.image.BufferedImage
Expand All @@ -17,7 +17,7 @@ import javax.imageio.ImageIO
open class ImageActor(
prompt: String = "Transform the user request into an image generation prompt that the user will like",
name: String? = null,
textModel: OpenAITextModel,
textModel: TextModel,
val imageModel: ImageModels = ImageModels.DallE2,
temperature: Double = 0.3,
val width: Int = 1024,
Expand Down Expand Up @@ -81,7 +81,7 @@ open class ImageActor(
return ImageResponseImpl(text, api = this.openAI!!)
}

override fun withModel(model: ChatModels): ImageActor = ImageActor(
override fun withModel(model: ChatModel): ImageActor = ImageActor(
prompt = prompt,
name = name,
textModel = model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import com.simiacryptus.jopenai.ChatClient
import com.simiacryptus.jopenai.describe.AbbrevWhitelistYamlDescriber
import com.simiacryptus.jopenai.describe.TypeDescriber
import com.simiacryptus.jopenai.models.ApiModel
import com.simiacryptus.jopenai.models.ChatModels
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.jopenai.models.OpenAIModels
import com.simiacryptus.jopenai.models.OpenAITextModel
import com.simiacryptus.jopenai.models.TextModel
import com.simiacryptus.jopenai.util.ClientUtil.toContentList
import com.simiacryptus.skyenet.core.util.MultiExeption
import com.simiacryptus.util.JsonUtil
Expand All @@ -19,9 +19,9 @@ open class ParsedActor<T : Any>(
val exampleInstance: T? = resultClass?.getConstructor()?.newInstance(),
prompt: String = "",
name: String? = resultClass?.simpleName,
model: OpenAITextModel = OpenAIModels.GPT4o,
model: TextModel = OpenAIModels.GPT4o,
temperature: Double = 0.3,
val parsingModel: OpenAITextModel = OpenAIModels.GPT4oMini,
val parsingModel: TextModel = OpenAIModels.GPT4oMini,
val deserializerRetries: Int = 2,
open val describer: TypeDescriber = object : AbbrevWhitelistYamlDescriber(
"com.simiacryptus", "com.github.simiacryptus"
Expand Down Expand Up @@ -145,7 +145,7 @@ open class ParsedActor<T : Any>(
}
}

override fun withModel(model: ChatModels): ParsedActor<T> = ParsedActor(
override fun withModel(model: ChatModel): ParsedActor<T> = ParsedActor(
resultClass = resultClass,
prompt = prompt,
name = name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.simiacryptus.skyenet.core.actors

import com.simiacryptus.jopenai.API
import com.simiacryptus.jopenai.models.ApiModel
import com.simiacryptus.jopenai.models.ChatModels
import com.simiacryptus.jopenai.models.OpenAITextModel
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.jopenai.models.TextModel
import com.simiacryptus.jopenai.util.ClientUtil.toContentList

open class SimpleActor(
prompt: String,
name: String? = null,
model: OpenAITextModel,
model: TextModel,
temperature: Double = 0.3,
) : BaseActor<List<String>, String>(
prompt = prompt,
Expand All @@ -33,7 +33,7 @@ open class SimpleActor(
)
}

override fun withModel(model: ChatModels): SimpleActor = SimpleActor(
override fun withModel(model: ChatModel): SimpleActor = SimpleActor(
prompt = prompt,
name = name,
model = model,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.simiacryptus.skyenet.core.actors

import com.simiacryptus.jopenai.API
import com.simiacryptus.jopenai.OpenAIClient
import com.simiacryptus.jopenai.models.ApiModel
import com.simiacryptus.jopenai.models.ApiModel.ChatMessage
import com.simiacryptus.jopenai.OpenAIClient
import com.simiacryptus.jopenai.models.AudioModels
import com.simiacryptus.jopenai.models.ChatModels
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.jopenai.util.ClientUtil.toContentList

open class TextToSpeechActor(
name: String? = null,
val audioModel: AudioModels = AudioModels.TTS_HD,
val voice: String = "alloy",
val speed: Double = 1.0,
val models: ChatModels,
val models: ChatModel,
) : BaseActor<List<String>, SpeechResponse>(
prompt = "",
name = name,
Expand Down Expand Up @@ -59,7 +59,7 @@ open class TextToSpeechActor(
)


override fun withModel(model: ChatModels) = TextToSpeechActor(name, audioModel, voice, speed, model)
override fun withModel(model: ChatModel) = TextToSpeechActor(name, audioModel, voice, speed, model)
.also { it.openAI = this.openAI }
}

Loading

0 comments on commit c135230

Please sign in to comment.