Skip to content

Commit dc8abdb

Browse files
committed
feat(flow): add TaskFlow interface and implement in GenSqlFlow #81
- 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.
1 parent a324699 commit dc8abdb

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

exts/database/src/main/kotlin/cc/unitmesh/database/flow/GenSqlFlow.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cc.unitmesh.database.flow
22

33
import cc.unitmesh.database.DbContextActionProvider
44
import cc.unitmesh.devti.AutoDevBundle
5+
import cc.unitmesh.devti.flow.TaskFlow
56
import cc.unitmesh.devti.gui.chat.ChatCodingPanel
67
import cc.unitmesh.devti.llms.LLMProvider
78
import cc.unitmesh.devti.template.TemplateRender
@@ -16,10 +17,10 @@ class GenSqlFlow(
1617
val ui: ChatCodingPanel,
1718
val llm: LLMProvider,
1819
val project: Project
19-
) {
20+
) : TaskFlow {
2021
private val logger = logger<GenSqlFlow>()
2122

22-
fun clarify(): String {
23+
override fun clarify(): String {
2324
val stepOnePrompt = generateStepOnePrompt(genSqlContext, actions)
2425

2526
LLMCoroutineScope.scope(project).runCatching {
@@ -35,7 +36,8 @@ class GenSqlFlow(
3536
}
3637
}
3738

38-
fun generate(tableNames: List<String>): String {
39+
override fun design(context: Any): String {
40+
val tableNames = context as List<String>
3941
val stepTwoPrompt = generateStepTwoPrompt(genSqlContext, actions, tableNames)
4042

4143
LLMCoroutineScope.scope(project).runCatching {

exts/database/src/main/kotlin/cc/unitmesh/database/flow/GenSqlTask.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class GenSqlTask(
3636

3737
indicator.fraction = 0.6
3838
indicator.text = AutoDevBundle.message("migration.database.sql.generate.generate")
39-
val sqlScript = flow.generate(tableNames)
39+
val sqlScript = flow.design(tableNames)
4040

4141
logger.info("SQL Script: $sqlScript")
4242
WriteCommandAction.runWriteCommandAction(project, "Gen SQL", "cc.unitmesh.livingDoc", {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package cc.unitmesh.devti.flow
2+
3+
interface TaskFlow {
4+
fun clarify(): String
5+
fun design(context: Any): String {
6+
return ""
7+
}
8+
fun execute(): String {
9+
return ""
10+
}
11+
}

0 commit comments

Comments
 (0)