Skip to content

Commit

Permalink
1.2.6 (#104)
Browse files Browse the repository at this point in the history
* 1.2.6

* wip

* 1.1.6

* fixes
  • Loading branch information
acharneski authored Oct 1, 2024
1 parent 22fc44e commit 9a5eac1
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 58 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.1.5</version>
<version>1.1.6</version>
</dependency>
```

Gradle:

```groovy
implementation group: 'com.simiacryptus', name: 'skyenet', version: '1.1.5'
implementation group: 'com.simiacryptus', name: 'skyenet', version: '1.1.6'
```

```kotlin
implementation("com.simiacryptus:skyenet:1.1.5")
implementation("com.simiacryptus:skyenet:1.1.6")
```

### 🌟 To Use
Expand Down
4 changes: 0 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ fun properties(key: String) = project.findProperty(key).toString()
group = properties("libraryGroup")
version = properties("libraryVersion")

//plugins {
// id("org.jetbrains.kotlin.jvm") version "2.0.20"
//}

tasks {
wrapper {
gradleVersion = properties("gradleVersion")
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 hsqldb_version = "2.7.2"

dependencies {

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

implementation("org.apache.commons:commons-text:1.11.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ package com.simiacryptus.skyenet.core.util
import java.io.File

fun getModuleRootForFile(file: File): File {
if (file.isFile) {
return getModuleRootForFile(file.parentFile)
}
var current = file
while (current.parentFile != null) {
do {
if (current.resolve(".git").exists()) {
return current
}
current = current.parentFile
}
current = current.parentFile ?: break
} while (true)
return file
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Gradle Releases -> https://github.com/gradle/gradle/releases
libraryGroup = com.simiacryptus.skyenet
libraryVersion = 1.2.5
libraryVersion = 1.2.6
gradleVersion = 7.6.1
kotlin.daemon.jvmargs=-Xmx2g
1 change: 0 additions & 1 deletion kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ tasks {
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
jvmArgs(
"-Xlog:class+load=info:classloader.log",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/java.lang=ALL-UNNAMED"
Expand Down
2 changes: 1 addition & 1 deletion webui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ val jackson_version = "2.17.2"

dependencies {

implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.1.5") {
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.1.6") {
exclude(group = "org.slf4j")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,30 @@ fun SocketManagerBase.addApplyFileDiffLinks(
val headers = headerPattern.findAll(response).map { it.range to it.groupValues[1] }.toList()
val findAll = codeblockPattern.findAll(response).toList()
val codeblocks = findAll.filter { block ->
val header = headers.lastOrNull { it.first.last <= block.range.first }
if (header == null) {
return@filter false
try {
val header = headers.lastOrNull { it.first.last <= block.range.first }
if (header == null) {
return@filter false
}
val filename = resolve(root, header.second)
!root.resolve(filename).toFile().exists()
} catch (e: Throwable) {
log.info("Error processing code block", e)
false
}
val filename = resolve(root, header.second)
!root.resolve(filename).toFile().exists()
}.map { it.range to it }.toList()
val patchBlocks = findAll.filter { block ->
val header = headers.lastOrNull { it.first.last <= block.range.first }
if (header == null) {
return@filter false
try {
val header = headers.lastOrNull { it.first.last <= block.range.first }
if (header == null) {
return@filter false
}
val filename = resolve(root, header.second)
root.resolve(filename).toFile().exists()
} catch (e: Throwable) {
log.info("Error processing code block", e)
false
}
val filename = resolve(root, header.second)
root.resolve(filename).toFile().exists()
}.map { it.range to it }.toList()
// Process diff blocks and add patch links
val withPatchLinks: String = patchBlocks.fold(response) { markdown, diffBlock ->
Expand Down Expand Up @@ -156,11 +166,15 @@ fun resolve(root: Path, filename: String): String {
filename
}

if (!root.resolve(filename).toFile().exists()) {
root.toFile().listFilesRecursively().find { it.toString().replace("\\", "/").endsWith(filename.replace("\\", "/")) }
?.toString()?.apply {
filename = relativizeFrom(root)
}
try {
if (!root.resolve(filename).toFile().exists()) {
root.toFile().listFilesRecursively().find { it.toString().replace("\\", "/").endsWith(filename.replace("\\", "/")) }
?.toString()?.apply {
filename = relativizeFrom(root)
}
}
} catch (e: Throwable) {
log.error("Error resolving filename", e)
}

return filename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class AbstractTask<T : PlanTaskBase>(
Completed,
}

protected fun getPriorCode(planProcessingState: PlanProcessingState) =
protected open fun getPriorCode(planProcessingState: PlanProcessingState) =
planTask?.task_dependencies?.joinToString("\n\n\n") { dependency ->
"""
|# $dependency
Expand Down Expand Up @@ -59,7 +59,8 @@ abstract class AbstractTask<T : PlanTaskBase>(
plan: Map<String, PlanTaskBase>,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
api: API,
resultFn: (String) -> Unit
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ CommandAutoFix - Run a command and automatically fix any issues that arise
plan: Map<String, PlanTaskBase>,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
api: API,
resultFn: (String) -> Unit
) {
val semaphore = Semaphore(0)
val onComplete = {
Expand Down Expand Up @@ -91,7 +92,7 @@ CommandAutoFix - Run a command and automatically fix any issues that arise
ui = agent.ui,
task = task
)
planProcessingState.taskResult[taskId] = "Command Auto Fix completed"
resultFn("Command Auto Fix completed")
task.add(if (outputResult.exitCode == 0) {
if (agent.planSettings.autoFix) {
onComplete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ ForeachTask - Execute a task for each item in a list
plan: Map<String, PlanTaskBase>,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
api: API,
resultFn: (String) -> Unit
) {
val items =
planTask?.foreach_items ?: throw RuntimeException("No items specified for ForeachTask")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ class PlanCoordinator(
plan = plan,
planProcessingState = planProcessingState,
task = task1,
api = api
api = api,
resultFn = { planProcessingState.taskResult[taskId] = it }
)
} catch (e: Throwable) {
log.warn("Error during task execution", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.simiacryptus.skyenet.apps.plan.PlanUtil.executionOrder
import com.simiacryptus.skyenet.apps.plan.PlanUtil.filterPlan
import com.simiacryptus.skyenet.apps.plan.PlanUtil.render
import com.simiacryptus.skyenet.apps.plan.PlanningTask.PlanningTaskData
import com.simiacryptus.skyenet.apps.plan.file.AbstractFileTask
import com.simiacryptus.skyenet.core.actors.ParsedResponse
import com.simiacryptus.skyenet.webui.application.ApplicationInterface
import com.simiacryptus.skyenet.webui.session.SessionTask
Expand Down Expand Up @@ -59,7 +58,8 @@ class PlanningTask(
plan: Map<String, PlanTaskBase>,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
api: API,
resultFn: (String) -> Unit
) {
val newTask = agent.ui.newTask(false).apply { add(placeholder) }
fun toInput(s: String) = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.simiacryptus.jopenai.describe.Description
import com.simiacryptus.jopenai.models.ApiModel
import com.simiacryptus.skyenet.apps.coding.CodingAgent
import com.simiacryptus.skyenet.apps.plan.RunShellCommandTask.RunShellCommandTaskData
import com.simiacryptus.skyenet.apps.plan.file.AbstractFileTask
import com.simiacryptus.skyenet.core.actors.CodingActor
import com.simiacryptus.skyenet.interpreter.ProcessInterpreter
import com.simiacryptus.skyenet.webui.session.SessionTask
Expand Down Expand Up @@ -73,7 +72,8 @@ Note: This task is for running simple and safe commands. Avoid executing command
plan: Map<String, PlanTaskBase>,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
api: API,
resultFn: (String) -> Unit
) {
val semaphore = Semaphore(0)
object : CodingAgent<ProcessInterpreter>(
Expand Down Expand Up @@ -114,7 +114,7 @@ Note: This task is for running simple and safe commands. Avoid executing command
response: CodingActor.CodeResult
): String {
return ui.hrefLink("Accept", "href-link play-button") {
planProcessingState.taskResult[taskId] = response.let {
response.let {
"""
|## Shell Command Output
|
Expand All @@ -127,7 +127,7 @@ Note: This task is for running simple and safe commands. Avoid executing command
|${TRIPLE_TILDE}
|
""".trimMargin()
}
}.apply { resultFn(this) }
semaphore.release()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ abstract class AbstractAnalysisTask<T : AbstractFileTask.FileTaskBase>(
plan: Map<String, PlanTaskBase>,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
api: API,
resultFn: (String) -> Unit
) {
val analysisResult = analysisActor.answer(
listOf(
Expand All @@ -47,7 +48,7 @@ abstract class AbstractAnalysisTask<T : AbstractFileTask.FileTaskBase>(
"${getAnalysisInstruction()}:\n${getInputFileCode()}",
).filter { it.isNotBlank() }, api = api
)
planProcessingState.taskResult[taskId] = analysisResult
resultFn(analysisResult)
applyChanges(agent, task, analysisResult, api)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class DocumentationTask(
plan: Map<String, PlanTaskBase>,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
api: API,
resultFn: (String) -> Unit
) {
val semaphore = Semaphore(0)
val onComplete = {
Expand All @@ -78,7 +79,7 @@ class DocumentationTask(
"Items to document: ${itemsToDocument.joinToString(", ")}"
).filter { it.isNotBlank() }, api
)
planProcessingState.taskResult[taskId] = docResult
resultFn(docResult)
if (agent.planSettings.autoFix) {
task.complete()
onComplete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class FileModificationTask(
plan: Map<String, PlanTaskBase>,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
api: API,
resultFn: (String) -> Unit
) {
if (((planTask?.input_files ?: listOf()) + (planTask?.output_files ?: listOf())).isEmpty()) {
task.complete("No input files specified")
Expand All @@ -121,7 +122,7 @@ class FileModificationTask(
this.planTask?.task_description ?: "",
).filter { it.isNotBlank() }, api
)
planProcessingState.taskResult[taskId] = codeResult
resultFn(codeResult)
if (agent.planSettings.autoFix) {
val diffLinks = agent.ui.socketManager!!.addApplyFileDiffLinks(
root = agent.root,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class InquiryTask(
When generating insights, consider the existing project context and focus on information that is directly relevant and applicable.
Focus on generating insights and information that support the task types available in the system (${
planSettings.taskSettings.filter { it.value.enabled }.keys.joinToString(", ")
}).
planSettings.taskSettings.filter { it.value.enabled }.keys.joinToString(", ")}).
This will ensure that the inquiries are tailored to assist in the planning and execution of tasks within the system's framework.
""".trimMargin(),
model = planSettings.getTaskSettings(TaskType.valueOf(planTask?.task_type!!)).model
Expand All @@ -59,13 +58,11 @@ class InquiryTask(
)
}

override fun promptSegment(): String {
return """
Inquiry - Answer questions by reading in files and providing a summary that can be discussed with and approved by the user
** Specify the questions and the goal of the inquiry
** List input files to be examined when answering the questions
""".trimMargin()
}
override fun promptSegment() = """
|Inquiry - Answer questions by reading in files and providing a summary that can be discussed with and approved by the user
| ** Specify the questions and the goal of the inquiry
| ** List input files to be examined when answering the questions
""".trimMargin()

override fun run(
agent: PlanCoordinator,
Expand All @@ -74,7 +71,8 @@ class InquiryTask(
plan: Map<String, PlanTaskBase>,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
api: API,
resultFn: (String) -> Unit
) {
val toInput = { it: String ->
listOf<String>(
Expand Down Expand Up @@ -127,7 +125,7 @@ class InquiryTask(
).apply {
task.add(MarkdownUtil.renderMarkdown(this, ui = agent.ui))
}
planProcessingState.taskResult[taskId] = inquiryResult
resultFn(inquiryResult)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.simiacryptus.skyenet.webui.application.ApplicationServer
import com.simiacryptus.skyenet.webui.session.SessionTask
import com.simiacryptus.skyenet.webui.session.SocketManagerBase
import com.simiacryptus.skyenet.util.MarkdownUtil
import java.util.*

open class ChatSocketManager(
session: Session,
Expand Down Expand Up @@ -43,6 +44,13 @@ open class ChatSocketManager(
@Synchronized
override fun onRun(userMessage: String, socket: ChatSocket) {
val task = newTask()
val api = (api as ChatClient).getChildClient().apply {
val createFile = task.createFile(".logs/api-${UUID.randomUUID()}.log")
createFile.second?.apply {
logStreams += this.outputStream().buffered()
task.verbose("API log: <a href=\"file:///$this\">$this</a>")
}
}
val responseContents = renderResponse(userMessage, task)
task.echo(responseContents)
messages += ApiModel.ChatMessage(ApiModel.Role.user, userMessage.toContentList())
Expand Down

0 comments on commit 9a5eac1

Please sign in to comment.