Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski committed Dec 2, 2023
1 parent eb0630a commit 434c4fe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.simiacryptus.skyenet.core.actors

import com.fasterxml.jackson.annotation.JsonIgnore
import com.simiacryptus.jopenai.API
import com.simiacryptus.jopenai.ApiModel.*
import com.simiacryptus.jopenai.ClientUtil.toContentList
Expand Down Expand Up @@ -50,7 +49,7 @@ open class CodingActor(
}

val code: String
val status: CodeResult.Status
val status: Status
val result: ExecutionResult
}

Expand Down Expand Up @@ -176,17 +175,16 @@ open class CodingActor(
return executionResult
}

private inner class CodeResultImpl(
inner class CodeResultImpl(
vararg val messages: ChatMessage,
val input: CodeRequest,
val api: OpenAIClient,
val givenCode: String? = null,
private val input: CodeRequest,
private val api: OpenAIClient,
private val givenCode: String? = null,
) : CodeResult {
var _status = CodeResult.Status.Coding

override val status get() = _status

@JsonIgnore
override val code: String = givenCode ?: try {
implement(model)
} catch (ex: FailedToImplementException) {
Expand Down Expand Up @@ -263,6 +261,7 @@ open class CodingActor(


private val executionResult by lazy { execute(input.codePrefix, code) }

override val result get() = executionResult
}

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

import com.fasterxml.jackson.annotation.JsonIgnore
import com.simiacryptus.jopenai.API
import com.simiacryptus.jopenai.ApiModel
import com.simiacryptus.jopenai.ClientUtil.toContentList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ class CodingActorInterceptor(
}


override fun answer(vararg messages: ChatMessage, input: CodeRequest, api: API) =
functionInterceptor.wrap(messages, input)
{ messages, input -> inner.answer(*messages, input=input, api = api) }
override fun answer(vararg messages: ChatMessage, input: CodeRequest, api: API): CodeResult {
val codeResult = functionInterceptor.wrap(messages, input)
{ messages, input -> inner.answer(*messages, input = input, api = api).code }
return inner.CodeResultImpl(
messages=messages,
input=input,
api=api as com.simiacryptus.jopenai.OpenAIClient,
givenCode = codeResult
)
}

override fun execute(prefix: String, code: String) =
functionInterceptor.wrap(prefix, code)
Expand Down

0 comments on commit 434c4fe

Please sign in to comment.