Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski committed Nov 11, 2023
1 parent 3320200 commit 8f1a5fc
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 151 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ api.log.json
*.log.java
*.log
api.*
.skynet

.skynet.bak

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"<button class=\"cancel-button\" data-id=\"qwcvyd\">&times;</button><div><div><p>Calculate the median prime number from the range 1-1000</p>\n</div></div><div><div><pre><code class=\"language-kotlin\">\nfun main() {\n val primeNumbers = mutableListOf&lt;Int&gt;()\n \n for (number in 1..1000) {\n if (isPrime(number)) {\n primeNumbers.add(number)\n }\n }\n \n primeNumbers.sort()\n \n val median = if (primeNumbers.size % 2 == 0) {\n val middleIndex = primeNumbers.size / 2\n (primeNumbers[middleIndex - 1] + primeNumbers[middleIndex]) / 2.0\n } else {\n primeNumbers[primeNumbers.size / 2].toDouble()\n }\n \n println(&quot;The median prime number from the range 1-1000 is: $median&quot;)\n}\n\nfun isPrime(number: Int): Boolean {\n if (number &lt;= 1) {\n return false\n }\n \n for (i in 2 until number) {\n if (number % i == 0) {\n return false\n }\n }\n \n return true\n}\n\n</code></pre>\n<p><a class=\"href-link\" data-id=\"hwuiit\">▶</a></p>\n</div></div><div><div>Running...</div></div><div><pre>null</pre>\n<pre>11:34:55.431 [pool-12-thread-1] INFO c.s.skyenet.heart.KotlinInterpreter - Running:\n fun main() {\n\t val primeNumbers = mutableListOf<Int>()\n\t \n\t for (number in 1..1000) {\n\t if (isPrime(number)) {\n\t primeNumbers.add(number)\n\t }\n\t }\n\t \n\t primeNumbers.sort()\n\t \n\t val median = if (primeNumbers.size % 2 == 0) {\n\t val middleIndex = primeNumbers.size / 2\n\t (primeNumbers[middleIndex - 1] + primeNumbers[middleIndex]) / 2.0\n\t } else {\n\t primeNumbers[primeNumbers.size / 2].toDouble()\n\t }\n\t \n\t println(\"The median prime number from the range 1-1000 is: $median\")\n\t}\n\t\n\tfun isPrime(number: Int): Boolean {\n\t if (number <= 1) {\n\t return false\n\t }\n\t \n\t for (i in 2 until number) {\n\t if (number % i == 0) {\n\t return false\n\t }\n\t }\n\t \n\t return true\n\t}\n\n11:35:04.395 [pool-12-thread-1] INFO c.s.skyenet.actors.CodingActor - Result: null\n</pre></div>"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"<button class=\"cancel-button\" data-id=\"hvlauy\">&times;</button><div><div><p>This is the last message</p>\n</div></div><div><div><p>Isthay isay ethay astlay essagemay</p>\n</div></div>"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"<button class=\"cancel-button\" data-id=\"nakgfp\">&times;</button><div><div><p>Recite the pledge of allegiance (in pig latin)</p>\n</div></div><div><div><p>Eciteray ethay edgeplay ofay allegianceay (inay igpay atinlay)</p>\n</div></div>"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"<button class=\"cancel-button\" data-id=\"ozicdd\">&times;</button><div><div><p>I wish to have a longer conversation</p>\n</div></div><div><div><p>Ishway otay avehay alay ongerlay onversationcay</p>\n</div></div>"
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ repositories {
val kotlin_version = "1.9.20"
val jetty_version = "11.0.15"
val slf4j_version = "2.0.9"
val skyenet_version = "1.0.23"
val skyenet_version = "1.0.24"
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 = "com.simiacryptus.skyenet", name = "core", version = skyenet_version)
implementation(group = "com.simiacryptus.skyenet", name = "webui", version = skyenet_version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream

class GenerateProjectAction extends FileContextAction<Settings> {
static Logger logger = LoggerFactory.getLogger(GenerateProjectAction.class)
static Logger log = LoggerFactory.getLogger(GenerateProjectAction.class)


GenerateProjectAction() {
Expand Down Expand Up @@ -326,7 +326,7 @@ class GenerateProjectAction extends FileContextAction<Settings> {
)
// def progressVal = currentDraft.incrementAndGet().toDouble() / totalDrafts
// progress(progressVal)
// logger.info("Progress: $progressVal")
// log.info("Progress: $progressVal")
return new Pair(file.location, implement)
}
})
Expand Down Expand Up @@ -371,7 +371,7 @@ class GenerateProjectAction extends FileContextAction<Settings> {
)
// def progressVal = currentDraft.incrementAndGet().toDouble() / totalDrafts
// progress(progressVal)
// logger.info("Progress: $progressVal")
// log.info("Progress: $progressVal")
return new Pair(file.location, implement)
}
})
Expand Down Expand Up @@ -418,7 +418,7 @@ class GenerateProjectAction extends FileContextAction<Settings> {
)
// def progressVal = currentDraft.incrementAndGet().toDouble() / totalDrafts
// progress(progressVal)
// logger.info("Progress: $progressVal")
// log.info("Progress: $progressVal")
return new Pair(file.location, implement)
}
})
Expand Down Expand Up @@ -522,20 +522,20 @@ class GenerateProjectAction extends FileContextAction<Settings> {
entries.each { file, sourceCode ->
def relative = trimStart(trimEnd(file.file, '/'), ['/', '.']) ?: ""
if (new File(relative).isAbsolute()) {
logger.warn("Invalid path: $relative")
log.warn("Invalid path: $relative")
} else {
def outFile = new File(outputDir, relative)
outFile.parentFile.mkdirs()
def best = sourceCode.max { it.code.length() }
outFile.text = best.code
logger.debug("Wrote ${outFile.canonicalPath} (Resolved from $relative)")
log.debug("Wrote ${outFile.canonicalPath} (Resolved from $relative)")
generatedFiles << outFile
if (config.saveAlternates)
sourceCode.findAll { it != best }.eachWithIndex { alternate, index ->
def outFileAlternate = new File(outputDir, relative + ".${index + 1}")
outFileAlternate.parentFile.mkdirs()
outFileAlternate.text = alternate.code
logger.debug("Wrote ${outFileAlternate.canonicalPath} (Resolved from $relative)")
log.debug("Wrote ${outFileAlternate.canonicalPath} (Resolved from $relative)")
generatedFiles << outFileAlternate
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.github.simiacryptus.aicoder.util.UITools
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.project.Project
import com.simiacryptus.skyenet.body.WebSocketServer
import com.simiacryptus.skyenet.webui.WebSocketServer
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.server.handler.ContextHandlerCollection
import org.eclipse.jetty.webapp.WebAppContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.simiacryptus.aicoder.actions.dev
import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.intellij.openapi.project.Project
import com.simiacryptus.openai.OpenAIClient
import com.simiacryptus.skyenet.body.*
import com.simiacryptus.skyenet.webui.*
import org.eclipse.jetty.util.resource.Resource

class CodeChatServer(
Expand Down Expand Up @@ -43,7 +43,7 @@ rootMessageTrail =
messages += OpenAIClient.ChatMessage(OpenAIClient.ChatMessage.Role.user, userMessage)
val response = api.chat(chatRequest, model).choices.first()?.message?.content.orEmpty()
messages += OpenAIClient.ChatMessage(OpenAIClient.ChatMessage.Role.assistant, response)
messageTrail += ChatSessionFlexmark.renderMarkdown(response)
messageTrail += MarkdownUtil.renderMarkdown(response)
send(messageTrail)
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import java.util.*

class SimpleEnvelope(var value: String? = null)

@Suppress("MemberVisibilityCanBePrivate")
@State(name = "org.intellij.sdk.settings.AppSettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
class AppSettingsState : PersistentStateComponent<SimpleEnvelope> {
val listeningPort: Int = 8081
val listeningEndpoint: String = "localhost"
val modalTasks: Boolean = false
var suppressErrors: Boolean = false
var apiLog: Boolean = false
private var apiLog: Boolean = false
var apiBase = "https://api.openai.com/v1"
var apiKey = ""
var temperature = 0.1
Expand All @@ -33,15 +32,15 @@ class AppSettingsState : PersistentStateComponent<SimpleEnvelope> {
val editorActions = ActionSettingsRegistry()
val fileActions = ActionSettingsRegistry()

val recentCommands = mutableMapOf<String,MRUItems>()
private val recentCommands = mutableMapOf<String,MRUItems>()

fun createChatRequest(): ChatRequest {
return createChatRequest(defaultChatModel())
}

fun defaultChatModel() = if (useGPT4) OpenAIClient.Models.GPT4 else OpenAIClient.Models.GPT35Turbo

fun createChatRequest(model: OpenAIClient.Model): ChatRequest {
private fun createChatRequest(model: OpenAIClient.Model): ChatRequest {
val chatRequest = ChatRequest()
chatRequest.model = model.modelName
chatRequest.temperature = temperature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import javax.swing.ListModel

class ModelSelectionWidgetFactory : StatusBarWidgetFactory {
companion object {
val logger = org.slf4j.LoggerFactory.getLogger(ModelSelectionWidgetFactory::class.java)
val log = org.slf4j.LoggerFactory.getLogger(ModelSelectionWidgetFactory::class.java)
}

class ModelSelectionWidget : StatusBarWidget, StatusBarWidget.MultipleTextValuesPresentation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import javax.swing.event.ChangeListener

class TemperatureControlWidgetFactory : StatusBarWidgetFactory {
companion object {
val logger = org.slf4j.LoggerFactory.getLogger(TemperatureControlWidgetFactory::class.java)
val log = org.slf4j.LoggerFactory.getLogger(TemperatureControlWidgetFactory::class.java)
val pool = Executors.newCachedThreadPool()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean

class TokenCountWidgetFactory : StatusBarWidgetFactory {
companion object {
val logger = org.slf4j.LoggerFactory.getLogger(TokenCountWidgetFactory::class.java)
val log = org.slf4j.LoggerFactory.getLogger(TokenCountWidgetFactory::class.java)
val workQueue = LinkedBlockingDeque<Runnable>()
val pool = ThreadPoolExecutor(
/* corePoolSize = */ 1, /* maximumPoolSize = */ 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class PsiTranslationTree(
fun getTranslatedDocument(): CharSequence = try {
var translated = translatedResult.toString()
if (!stubs.isEmpty()) {
logger.warn(
log.warn(
"Translating ${stubs.size} stubs in ${stubId ?: "---"} - Initial Code: \n```\n ${
translationText().replace(
"\n",
Expand All @@ -112,7 +112,7 @@ class PsiTranslationTree(
val regex = child.getStubRegex(targetLanguage, translated)
val childDoc = child.getTranslatedDocument().toString()
val findAll = regex.findAll(translated).toList()
logger.warn(
log.warn(
"Replacing ${findAll.size} instances of ${child.stubId} with: \n```\n ${
childDoc.replace(
"\n",
Expand All @@ -123,7 +123,7 @@ class PsiTranslationTree(
translated.replace(regex, childDoc.replace("\$", "\\\$"))
}
}
logger.warn("Translation for ${stubId ?: "---"}: \n```\n ${translated.replace("\n", "\n ")}\n```\n")
log.warn("Translation for ${stubId ?: "---"}: \n```\n ${translated.replace("\n", "\n ")}\n```\n")
translated
} catch (e: InterruptedException) {
throw RuntimeException(e)
Expand Down Expand Up @@ -223,7 +223,7 @@ class PsiTranslationTree(

companion object {

val logger = Logger.getInstance(PsiTranslationTree::class.java)
val log = Logger.getInstance(PsiTranslationTree::class.java)

fun parseFile(
psiFile: PsiFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package com.simiacryptus.skyenet.heart
import com.simiacryptus.skyenet.Heart
import java.lang.reflect.Method

@Suppress("unused")
open class WeakGroovyInterpreter(defs: java.util.Map<String, Object>) : Heart {

private val shell: Any
Expand Down
9 changes: 0 additions & 9 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,6 @@
<add-to-group group-id="com.github.simiacryptus.aicoder.ui.ProjectMenu" anchor="first"/>
</action>

<action class="com.github.simiacryptus.aicoder.actions.dev.LaunchSkyenetAction"
text="_Launch Skyenet"
description="Launch Skyenet">
<!--DOC
The `Launch Skyenet` action opens the Skyenet interactive auto-scritping interface.
-->
<add-to-group group-id="com.github.simiacryptus.aicoder.ui.ProjectMenu" anchor="first"/>
</action>

<action class="com.github.simiacryptus.aicoder.actions.generic.CreateFileAction"
text="_Create File"
description="Create file">
Expand Down

0 comments on commit 8f1a5fc

Please sign in to comment.