Skip to content

Commit f532d1e

Browse files
committed
fix(counit): fix syntax error issue
1 parent b1337ca commit f532d1e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/kotlin/cc/unitmesh/devti/counit/CoUnitPreProcessor.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ class CoUnitPreProcessor(val project: Project) {
7272
val queryResult = coUnitPromptGenerator.semanticQuery(explain)
7373

7474
val related = buildDocAsContext(queryResult)
75+
if (related.isEmpty()) {
76+
val noResultTip = "no related API found"
77+
llmProvider.appendLocalMessage(noResultTip, ChatRole.Assistant)
78+
ui.addMessage(noResultTip, false, noResultTip)
79+
return@launch
80+
}
81+
7582
llmProvider.appendLocalMessage(related, ChatRole.User)
7683

7784
ApplicationManager.getApplication().invokeLater {
@@ -85,21 +92,21 @@ class CoUnitPreProcessor(val project: Project) {
8592
val normalDoc = queryResult.normalQuery
8693
if (normalDoc.isNotEmpty()) {
8794
sb.append("here is related API to origin query's result: \n```markdown\n")
88-
sb.append(Json.encodeToString(normalDoc[0].displayText))
95+
sb.append(normalDoc[0].displayText)
8996
sb.append("\n```\n")
9097
}
9198

9299
val nature = queryResult.natureLangQuery
93100
if (nature.isNotEmpty()) {
94101
sb.append("here is nature language query's result: \n```markdown\n")
95-
sb.append(Json.encodeToString(nature[0].displayText))
102+
sb.append(nature[0].displayText)
96103
sb.append("\n```\n")
97104
}
98105

99106
val hyde = queryResult.hypotheticalDocument
100107
if (hyde.isNotEmpty()) {
101108
sb.append("here is hypothetical document's result: \n```markdown\n")
102-
sb.append(Json.encodeToString(hyde[0].displayText))
109+
sb.append(hyde[0].displayText)
103110
sb.append("\n```\n")
104111
}
105112

0 commit comments

Comments
 (0)