-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1.0.90 * new tasks, refactors * foreach
- Loading branch information
1 parent
0bc0796
commit d30156f
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/ForeachTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.simiacryptus.skyenet.apps.plan | ||
|
||
import com.simiacryptus.skyenet.TabbedDisplay | ||
import com.simiacryptus.skyenet.core.actors.ParsedResponse | ||
import com.simiacryptus.skyenet.webui.session.SessionTask | ||
import org.slf4j.LoggerFactory | ||
|
||
class ForeachTask( | ||
settings: Settings, | ||
planTask: PlanTask | ||
) : AbstractTask(settings, planTask) { | ||
|
||
override fun promptSegment(): String { | ||
return """ | ||
ForeachTask - Execute a task for each item in a list | ||
** Specify the list of items to iterate over | ||
** Define the task to be executed for each item | ||
""".trimIndent() | ||
} | ||
|
||
override fun run( | ||
agent: PlanCoordinator, | ||
taskId: String, | ||
userMessage: String, | ||
plan: ParsedResponse<PlanCoordinator.TaskBreakdownResult>, | ||
genState: PlanCoordinator.GenState, | ||
task: SessionTask, | ||
taskTabs: TabbedDisplay | ||
) { | ||
val items = planTask.foreachItems ?: throw RuntimeException("No items specified for ForeachTask") | ||
items.forEachIndexed { index, item -> | ||
val subTask = agent.ui.newTask(false) | ||
task.add(subTask.placeholder) | ||
|
||
// Create a new PlanTask for each item, copying the original task's properties | ||
val itemTask = planTask.copy( | ||
description = "${planTask.description} - Item $index: $item", | ||
foreachItems = null // Remove the foreach items to prevent infinite recursion | ||
) | ||
|
||
// Execute the task for this item | ||
val subTaskImpl = settings.getImpl(itemTask) | ||
subTaskImpl.run(agent, "$taskId-$index", userMessage, plan, genState, subTask, taskTabs) | ||
} | ||
task.complete("Completed ForeachTask for ${items.size} items") | ||
} | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(ForeachTask::class.java) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ enum class TaskType { | |
SecurityAudit, | ||
PerformanceAnalysis, | ||
RefactorTask, | ||
ForeachTask, | ||
} |