Skip to content

Commit cbc1d02

Browse files
committed
refactor: rename for text
1 parent 6d46cc5 commit cbc1d02

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/main/kotlin/cc/unitmesh/devti/prompt/openai/OpenAIExecutor.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,31 @@ class OpenAIExecutor(val openAIKey: String, val version: String) : AiExecutor, D
3939
}
4040

4141
override fun fillStoryDetail(project: SimpleProjectInfo, story: String): String {
42-
val promptText = promptGenerator.fillStoryDetail(project, story)
42+
val promptText = promptGenerator.storyDetail(project, story)
4343
return runBlocking {
4444
val prompt = prompt(promptText)
4545
return@runBlocking prompt
4646
}
4747
}
4848

4949
override fun analysisEndpoint(storyDetail: String, classes: List<DtClass>): String {
50-
val promptText = promptGenerator.fillEndpoint(storyDetail, classes)
50+
val promptText = promptGenerator.createEndpoint(storyDetail, classes)
5151
return runBlocking {
5252
val prompt = prompt(promptText)
5353
return@runBlocking prompt
5454
}
5555
}
5656

5757
override fun needUpdateMethodForController(targetEndpoint: String, clazz: DtClass, storyDetail: String): String {
58-
val promptText = promptGenerator.fillUpdateMethod(clazz, storyDetail)
58+
val promptText = promptGenerator.updateControllerMethod(clazz, storyDetail)
5959
logger.warn("needUpdateMethodForController prompt text: $promptText")
6060
return runBlocking {
6161
return@runBlocking prompt(promptText)
6262
}
6363
}
6464

6565
fun codeCompleteFor(text: @NlsSafe String, className: @NlsSafe String?): String {
66-
val promptText = promptGenerator.fillCodeComplete(text, className)
66+
val promptText = promptGenerator.codeComplete(text, className)
6767
logger.warn("codeCompleteFor prompt text: $promptText")
6868
return runBlocking {
6969
val prompt = prompt(promptText)

src/main/kotlin/cc/unitmesh/devti/prompt/openai/PromptGenerator.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.io.InputStream
88
class PromptGenerator() {
99
// 1. read resources/prompts/create_story_detail.txt
1010
// 2. replace {project} with project name
11-
fun fillStoryDetail(project: SimpleProjectInfo, story: String): String {
11+
fun storyDetail(project: SimpleProjectInfo, story: String): String {
1212
val promptText: InputStream =
1313
this::class.java.classLoader.getResourceAsStream("prompts/create_story_detail.txt")!!
1414
val promptTextString = promptText.bufferedReader().use { it.readText() }
@@ -17,15 +17,15 @@ class PromptGenerator() {
1717
.replace("{story}", story)
1818
}
1919

20-
fun fillEndpoint(storyDetail: String, files: List<DtClass>): String {
20+
fun createEndpoint(storyDetail: String, files: List<DtClass>): String {
2121
val promptText: InputStream = this::class.java.classLoader.getResourceAsStream("prompts/create_endpoint.txt")!!
2222
val promptTextString = promptText.bufferedReader().use { it.readText() }
2323
return promptTextString
2424
.replace("{controllers}", files.map { it.name }.joinToString(","))
2525
.replace("{storyDetail}", storyDetail)
2626
}
2727

28-
fun fillUpdateMethod(targetClazz: DtClass, storyDetail: String): String {
28+
fun updateControllerMethod(targetClazz: DtClass, storyDetail: String): String {
2929
val promptText: InputStream = this::class.java.classLoader.getResourceAsStream("prompts/update_controller_method.txt")!!
3030
val promptTextString = promptText.bufferedReader().use { it.readText() }
3131
return promptTextString
@@ -34,8 +34,7 @@ class PromptGenerator() {
3434
.replace("{storyDetail}", storyDetail)
3535
}
3636

37-
// code complete
38-
fun fillCodeComplete(methodCode: String, className: @NlsSafe String?): String {
37+
fun codeComplete(methodCode: String, className: @NlsSafe String?): String {
3938
val promptText: InputStream = this::class.java.classLoader.getResourceAsStream("prompts/code_complete.txt")!!
4039
val promptTextString = promptText.bufferedReader().use { it.readText() }
4140
return promptTextString

src/test/kotlin/cc/unitmesh/devti/prompt/openai/PromptGeneratorTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class PromptGeneratorTest {
1313
val projectInfo = SimpleProjectInfo("", "DevTi", "description")
1414
val story = "story information"
1515

16-
val result = promptGenerator.fillStoryDetail(projectInfo, story)
16+
val result = promptGenerator.storyDetail(projectInfo, story)
1717
assertEquals(
1818
"""你是一个敏捷项目的 BA,请根据如下的信息,编写用户故事。
1919
@@ -42,7 +42,7 @@ AC 1: xxx
4242
val promptGenerator = PromptGenerator()
4343
val storyDetail = "用户故事:可以选择宝贝出行服务"
4444
val files: List<DtClass> = listOf(DtClass("TaxiController", emptyList()), DtClass("GpsController", emptyList()))
45-
val result = promptGenerator.fillEndpoint(storyDetail, files)
45+
val result = promptGenerator.createEndpoint(storyDetail, files)
4646
assertEquals("""请根据下面的用户故事 和 Controller 列表。要求:
4747
4848
1. 返回最合适的 Controller 名字

0 commit comments

Comments
 (0)