Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.21 #122

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.20
libraryVersion=1.2.21
gradleVersion=7.6.1
kotlin.daemon.jvmargs=-Xmx4g

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package com.simiacryptus.skyenet.apps.general
import com.simiacryptus.diff.FileValidationUtils
import com.simiacryptus.jopenai.ChatClient
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.jopenai.models.TextModel
import com.simiacryptus.skyenet.core.platform.Session
import com.simiacryptus.skyenet.set
import com.simiacryptus.skyenet.webui.session.SessionTask
Expand Down Expand Up @@ -98,8 +97,7 @@ class CmdPatchApp(
}

override fun output(task: SessionTask): OutputResult = run {
val command =
listOf(settings.executable.absolutePath) + settings.arguments.split(" ").filter(String::isNotBlank)
val command = listOf(settings.executable.absolutePath) + settings.arguments.split(" ").filter(String::isNotBlank)
val processBuilder = ProcessBuilder(command).directory(settings.workingDirectory)
// Pass the current environment to the subprocess
processBuilder.environment().putAll(System.getenv())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ abstract class PatchApp(
val socketManager = super.newSession(user, session)
val ui = (socketManager as ApplicationSocketManager).applicationInterface
val task = ui.newTask()
Retryable(
lateinit var retry : Retryable
var retries = 3
retry = Retryable(
ui = ui,
task = task,
process = { content ->
val newTask = ui.newTask(false)
newTask.add("Running Command")
Thread {
run(ui, newTask)
val result = run(ui, newTask)
if (result.exitCode != 0 && retries-- > 0) {
retry.retry()
}
}.start()
newTask.placeholder
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import com.simiacryptus.jopenai.API
import com.simiacryptus.jopenai.ChatClient
import com.simiacryptus.jopenai.OpenAIClient
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.jopenai.models.TextModel
import com.simiacryptus.skyenet.apps.plan.*
import com.simiacryptus.skyenet.apps.plan.file.InquiryTask.InquiryTaskData
import com.simiacryptus.skyenet.apps.plan.file.InquiryTask.InquiryTaskConfigData
import com.simiacryptus.skyenet.core.platform.Session
import com.simiacryptus.skyenet.core.platform.model.User
import com.simiacryptus.skyenet.util.MarkdownUtil
Expand Down Expand Up @@ -143,11 +142,11 @@ open class PlanChatApp(

}

protected open fun addRespondToChatTask(plan: Map<String, PlanTaskBase>): Map<String, PlanTaskBase> {
protected open fun addRespondToChatTask(plan: Map<String, TaskConfigBase>): Map<String, TaskConfigBase> {
val tasksByID = plan?.toMutableMap() ?: mutableMapOf()
val respondTaskId = "respond_to_chat"

tasksByID[respondTaskId] = InquiryTaskData(
tasksByID[respondTaskId] = InquiryTaskConfigData(
task_description = "Respond to the user's chat message based on the executed plan",
task_dependencies = tasksByID.keys.toList()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.io.File
import java.nio.file.Path


abstract class AbstractTask<T : PlanTaskBase>(
abstract class AbstractTask<T : TaskConfigBase>(
val planSettings: PlanSettings,
val planTask: T?
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.simiacryptus.jopenai.describe.Description
import com.simiacryptus.skyenet.Retryable
import com.simiacryptus.skyenet.apps.general.CmdPatchApp
import com.simiacryptus.skyenet.apps.general.PatchApp
import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskData
import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskConfigData
import com.simiacryptus.skyenet.util.MarkdownUtil
import com.simiacryptus.skyenet.webui.session.SessionTask
import org.slf4j.LoggerFactory
Expand All @@ -16,16 +16,16 @@ import java.util.concurrent.atomic.AtomicBoolean

class CommandAutoFixTask(
planSettings: PlanSettings,
planTask: CommandAutoFixTaskData?
) : AbstractTask<CommandAutoFixTaskData>(planSettings, planTask) {
planTask: CommandAutoFixTaskConfigData?
) : AbstractTask<CommandAutoFixTaskConfigData>(planSettings, planTask) {

class CommandAutoFixTaskData(
class CommandAutoFixTaskConfigData(
@Description("The commands to be executed with their respective working directories")
val commands: List<CommandWithWorkingDir>? = null,
task_description: String? = null,
task_dependencies: List<String>? = null,
state: TaskState? = null
) : PlanTaskBase(
) : TaskConfigBase(
task_type = TaskType.CommandAutoFix.name,
task_description = task_description,
task_dependencies = task_dependencies,
Expand Down Expand Up @@ -64,7 +64,7 @@ ${planSettings.commandAutoFixCommands?.joinToString("\n") { " * ${File(it).na
val semaphore = Semaphore(0)
val hasError = AtomicBoolean(false)
val onComplete = { semaphore.release() }
lateinit var retryable: Retryable
var retryable: Retryable? = null
retryable = Retryable(agent.ui, task = task) {
val task = agent.ui.newTask(false).apply { it.append(placeholder) }
this.planTask?.commands?.forEachIndexed { index, commandWithDir ->
Expand Down Expand Up @@ -137,7 +137,7 @@ ${planSettings.commandAutoFixCommands?.joinToString("\n") { " * ${File(it).na
) {
onComplete()
}
if(autoRetries-- > 0) retryable.retry()
if(autoRetries-- > 0) retryable?.retry()
s
})
task.placeholder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.simiacryptus.skyenet.apps.plan
import com.simiacryptus.jopenai.ChatClient
import com.simiacryptus.jopenai.OpenAIClient
import com.simiacryptus.jopenai.describe.Description
import com.simiacryptus.skyenet.core.platform.ApplicationServices
import com.simiacryptus.skyenet.webui.session.SessionTask
import org.slf4j.LoggerFactory
import java.io.BufferedReader
Expand All @@ -14,8 +13,8 @@ import java.util.concurrent.TimeUnit

class CommandSessionTask(
planSettings: PlanSettings,
planTask: CommandSessionTaskData?
) : AbstractTask<CommandSessionTask.CommandSessionTaskData>(planSettings, planTask) {
planTask: CommandSessionTaskConfigData?
) : AbstractTask<CommandSessionTask.CommandSessionTaskConfigData>(planSettings, planTask) {
companion object {
private val log = LoggerFactory.getLogger(CommandSessionTask::class.java)
private val activeSessions = ConcurrentHashMap<String, Process>()
Expand Down Expand Up @@ -68,7 +67,7 @@ class CommandSessionTask(
fun getActiveSessionCount(): Int = activeSessions.size
}

class CommandSessionTaskData(
class CommandSessionTaskConfigData(
@Description("The command to start the interactive session")
val command: List<String>,
@Description("Commands to send to the interactive session")
Expand All @@ -82,7 +81,7 @@ class CommandSessionTask(
task_description: String? = null,
task_dependencies: List<String>? = null,
state: TaskState? = null,
) : PlanTaskBase(
) : TaskConfigBase(
task_type = TaskType.CommandSession.name,
task_description = task_description,
task_dependencies = task_dependencies,
Expand Down Expand Up @@ -175,7 +174,7 @@ class CommandSessionTask(
}

private fun formatResults(
planTask: CommandSessionTaskData,
planTask: CommandSessionTaskConfigData,
results: List<String>
): String = buildString {
appendLine("## Command Session Results")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ package com.simiacryptus.skyenet.apps.plan
import com.simiacryptus.jopenai.ChatClient
import com.simiacryptus.jopenai.OpenAIClient
import com.simiacryptus.jopenai.describe.Description
import com.simiacryptus.skyenet.apps.plan.ForeachTask.ForeachTaskData
import com.simiacryptus.skyenet.apps.plan.ForeachTask.ForeachTaskConfigData
import com.simiacryptus.skyenet.apps.plan.PlanUtil.diagram
import com.simiacryptus.skyenet.apps.plan.PlanUtil.executionOrder
import com.simiacryptus.skyenet.webui.session.SessionTask
import org.slf4j.LoggerFactory

class ForeachTask(
planSettings: PlanSettings,
planTask: ForeachTaskData?
) : AbstractTask<ForeachTaskData>(planSettings, planTask) {
planTask: ForeachTaskConfigData?
) : AbstractTask<ForeachTaskConfigData>(planSettings, planTask) {

class ForeachTaskData(
@Description("A list of items over which the ForEach task will iterate. (Only applicable for ForeachTask tasks) Can be used to process outputs from previous tasks.")
class ForeachTaskConfigData(
@Description("A list of items over which the ForEach task will iterate. (Only applicable for ForeachTask tasks) Can be used to process outputs from previous tasks.")
val foreach_items: List<String>? = null,
@Description("A map of sub-task IDs to PlanTask objects to be executed for each item. (Only applicable for ForeachTask tasks) Allows for complex task dependencies and information flow within iterations.")
val foreach_subplan: Map<String, PlanTaskBase>? = null,
task_description: String? = null,
task_dependencies: List<String>? = null,
state: TaskState? = null,
) : PlanTaskBase(
@Description("A map of sub-task IDs to PlanTask objects to be executed for each item. (Only applicable for ForeachTask tasks) Allows for complex task dependencies and information flow within iterations.")
val foreach_subplan: Map<String, TaskConfigBase>? = null,
task_description: String? = null,
task_dependencies: List<String>? = null,
state: TaskState? = null,
) : TaskConfigBase(
task_type = TaskType.ForeachTask.name,
task_description = task_description,
task_dependencies = task_dependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import java.net.http.HttpResponse

class GitHubSearchTask(
planSettings: PlanSettings,
planTask: GitHubSearchTaskData?
) : AbstractTask<GitHubSearchTask.GitHubSearchTaskData>(planSettings, planTask) {
class GitHubSearchTaskData(
planTask: GitHubSearchTaskConfigData?
) : AbstractTask<GitHubSearchTask.GitHubSearchTaskConfigData>(planSettings, planTask) {
class GitHubSearchTaskConfigData(
@Description("The search query to use for GitHub search")
val search_query: String,
@Description("The type of GitHub search to perform (code, commits, issues, repositories, topics, users)")
Expand All @@ -31,7 +31,7 @@ class GitHubSearchTask(
task_description: String? = null,
task_dependencies: List<String>? = null,
state: TaskState? = null,
) : PlanTaskBase(
) : TaskConfigBase(
task_type = TaskType.GitHubSearch.name,
task_description = task_description,
task_dependencies = task_dependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ import java.net.http.HttpResponse

class GoogleSearchTask(
planSettings: PlanSettings,
planTask: GoogleSearchTaskData?
) : AbstractTask<GoogleSearchTask.GoogleSearchTaskData>(planSettings, planTask) {
class GoogleSearchTaskData(
planTask: GoogleSearchTaskConfigData?
) : AbstractTask<GoogleSearchTask.GoogleSearchTaskConfigData>(planSettings, planTask) {
class GoogleSearchTaskConfigData(
@Description("The search query to use for Google search")
val search_query: String,
@Description("The number of results to return (max 10)")
val num_results: Int = 5,
task_description: String? = null,
task_dependencies: List<String>? = null,
state: TaskState? = null,
) : PlanTaskBase(
) : TaskConfigBase(
task_type = TaskType.GoogleSearch.name,
task_description = task_description,
task_dependencies = task_dependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ class PlanCoordinator(
}

fun executePlan(
plan: Map<String, PlanTaskBase>,
task: SessionTask,
userMessage: String,
api: API,
api2: OpenAIClient,
plan: Map<String, TaskConfigBase>,
task: SessionTask,
userMessage: String,
api: API,
api2: OpenAIClient,
): PlanProcessingState {
val api = (api as ChatClient).getChildClient().apply {
val createFile = task.createFile(".logs/api-${UUID.randomUUID()}.log")
Expand Down Expand Up @@ -127,24 +127,24 @@ class PlanCoordinator(
return planProcessingState
}

private fun newState(plan: Map<String, PlanTaskBase>) =
private fun newState(plan: Map<String, TaskConfigBase>) =
PlanProcessingState(
subTasks = (filterPlan { plan }?.entries?.toTypedArray<Map.Entry<String, PlanTaskBase>>()
subTasks = (filterPlan { plan }?.entries?.toTypedArray<Map.Entry<String, TaskConfigBase>>()
?.associate { it.key to it.value } ?: mapOf()).toMutableMap()
)

fun executePlan(
task: SessionTask,
diagramBuffer: StringBuilder?,
subTasks: Map<String, PlanTaskBase>,
diagramTask: SessionTask,
planProcessingState: PlanProcessingState,
taskIdProcessingQueue: MutableList<String>,
pool: ThreadPoolExecutor,
userMessage: String,
plan: Map<String, PlanTaskBase>,
api: API,
api2: OpenAIClient,
task: SessionTask,
diagramBuffer: StringBuilder?,
subTasks: Map<String, TaskConfigBase>,
diagramTask: SessionTask,
planProcessingState: PlanProcessingState,
taskIdProcessingQueue: MutableList<String>,
pool: ThreadPoolExecutor,
userMessage: String,
plan: Map<String, TaskConfigBase>,
api: API,
api2: OpenAIClient,
) {
val sessionTask = ui.newTask(false).apply { task.add(placeholder) }
val api = (api as ChatClient).getChildClient().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import com.simiacryptus.skyenet.webui.session.SessionTask
import java.util.concurrent.Future

data class PlanProcessingState(
val subTasks: Map<String, PlanTaskBase>,
val tasksByDescription: MutableMap<String?, PlanTaskBase> = subTasks.entries.toTypedArray()
val subTasks: Map<String, TaskConfigBase>,
val tasksByDescription: MutableMap<String?, TaskConfigBase> = subTasks.entries.toTypedArray()
.associate { it.value.task_description to it.value }.toMutableMap(),
val taskIdProcessingQueue: MutableList<String> = PlanUtil.executionOrder(subTasks).toMutableList(),
val taskResult: MutableMap<String, String> = mutableMapOf(),
val completedTasks: MutableList<String> = mutableListOf(),
val taskFutures: MutableMap<String, Future<*>> = mutableMapOf(),
val uitaskMap: MutableMap<String, SessionTask> = mutableMapOf()
val taskIdProcessingQueue: MutableList<String> = PlanUtil.executionOrder(subTasks).toMutableList(),
val taskResult: MutableMap<String, String> = mutableMapOf(),
val completedTasks: MutableList<String> = mutableListOf(),
val taskFutures: MutableMap<String, Future<*>> = mutableMapOf(),
val uitaskMap: MutableMap<String, SessionTask> = mutableMapOf()
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package com.simiacryptus.skyenet.apps.plan

import com.simiacryptus.jopenai.describe.AbbrevWhitelistYamlDescriber
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskData
import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskConfigData
import com.simiacryptus.skyenet.apps.plan.PlanUtil.isWindows
import com.simiacryptus.skyenet.apps.plan.PlanningTask.PlanningTaskData
import com.simiacryptus.skyenet.apps.plan.PlanningTask.PlanningTaskConfigData
import com.simiacryptus.skyenet.apps.plan.PlanningTask.TaskBreakdownResult
import com.simiacryptus.skyenet.apps.plan.TaskType.Companion.getAvailableTaskTypes
import com.simiacryptus.skyenet.apps.plan.TaskType.Companion.getImpl
import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskData
import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskConfigData
import com.simiacryptus.skyenet.core.actors.ParsedActor


Expand Down Expand Up @@ -144,7 +144,7 @@ ${taskType.name}:
companion object {
var exampleInstance = TaskBreakdownResult(
tasksByID = mapOf(
"1" to CommandAutoFixTaskData(
"1" to CommandAutoFixTaskConfigData(
task_description = "Task 1",
task_dependencies = listOf(),
commands = listOf(
Expand All @@ -154,13 +154,13 @@ ${taskType.name}:
)
)
),
"2" to FileModificationTaskData(
"2" to FileModificationTaskConfigData(
task_description = "Task 2",
task_dependencies = listOf("1"),
input_files = listOf("input2.txt"),
output_files = listOf("output2.txt"),
),
"3" to PlanningTaskData(
"3" to PlanningTaskConfigData(
task_description = "Task 3",
task_dependencies = listOf("2"),
)
Expand Down
Loading
Loading