Skip to content

Commit

Permalink
feat(flow): add TaskFlow interface and implement in GenSqlFlow #81
Browse files Browse the repository at this point in the history
- Added a new file `TaskFlow.kt` in the `cc.unitmesh.devti.flow` package.
- The `TaskFlow` interface defines three methods: `clarify()`, `design(context: Any)`, and `execute()`.
- Modified the `GenSqlFlow.kt` file to implement the `TaskFlow` interface.
- Updated the `clarify()` method to override the interface method.
- Updated the `design(context: Any)` method to override the interface method and added a type cast for the `context` parameter.
- The changes allow `GenSqlFlow` to implement the `TaskFlow` interface and provide the required functionality.
  • Loading branch information
phodal committed Jan 24, 2024
1 parent a324699 commit dc8abdb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Expand Up @@ -2,6 +2,7 @@ package cc.unitmesh.database.flow

import cc.unitmesh.database.DbContextActionProvider
import cc.unitmesh.devti.AutoDevBundle
import cc.unitmesh.devti.flow.TaskFlow
import cc.unitmesh.devti.gui.chat.ChatCodingPanel
import cc.unitmesh.devti.llms.LLMProvider
import cc.unitmesh.devti.template.TemplateRender
Expand All @@ -16,10 +17,10 @@ class GenSqlFlow(
val ui: ChatCodingPanel,
val llm: LLMProvider,
val project: Project
) {
) : TaskFlow {
private val logger = logger<GenSqlFlow>()

fun clarify(): String {
override fun clarify(): String {
val stepOnePrompt = generateStepOnePrompt(genSqlContext, actions)

LLMCoroutineScope.scope(project).runCatching {
Expand All @@ -35,7 +36,8 @@ class GenSqlFlow(
}
}

fun generate(tableNames: List<String>): String {
override fun design(context: Any): String {
val tableNames = context as List<String>
val stepTwoPrompt = generateStepTwoPrompt(genSqlContext, actions, tableNames)

LLMCoroutineScope.scope(project).runCatching {
Expand Down
Expand Up @@ -36,7 +36,7 @@ class GenSqlTask(

indicator.fraction = 0.6
indicator.text = AutoDevBundle.message("migration.database.sql.generate.generate")
val sqlScript = flow.generate(tableNames)
val sqlScript = flow.design(tableNames)

logger.info("SQL Script: $sqlScript")
WriteCommandAction.runWriteCommandAction(project, "Gen SQL", "cc.unitmesh.livingDoc", {
Expand Down
11 changes: 11 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/flow/TaskFlow.kt
@@ -0,0 +1,11 @@
package cc.unitmesh.devti.flow

interface TaskFlow {
fun clarify(): String
fun design(context: Any): String {
return ""
}
fun execute(): String {
return ""
}
}

0 comments on commit dc8abdb

Please sign in to comment.