Skip to content

Commit

Permalink
fix(counit): fix syntax error issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 25, 2023
1 parent b1337ca commit f532d1e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/kotlin/cc/unitmesh/devti/counit/CoUnitPreProcessor.kt
Expand Up @@ -72,6 +72,13 @@ class CoUnitPreProcessor(val project: Project) {
val queryResult = coUnitPromptGenerator.semanticQuery(explain)

val related = buildDocAsContext(queryResult)
if (related.isEmpty()) {
val noResultTip = "no related API found"
llmProvider.appendLocalMessage(noResultTip, ChatRole.Assistant)
ui.addMessage(noResultTip, false, noResultTip)
return@launch
}

llmProvider.appendLocalMessage(related, ChatRole.User)

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

val nature = queryResult.natureLangQuery
if (nature.isNotEmpty()) {
sb.append("here is nature language query's result: \n```markdown\n")
sb.append(Json.encodeToString(nature[0].displayText))
sb.append(nature[0].displayText)
sb.append("\n```\n")
}

val hyde = queryResult.hypotheticalDocument
if (hyde.isNotEmpty()) {
sb.append("here is hypothetical document's result: \n```markdown\n")
sb.append(Json.encodeToString(hyde[0].displayText))
sb.append(hyde[0].displayText)
sb.append("\n```\n")
}

Expand Down

0 comments on commit f532d1e

Please sign in to comment.