Skip to content

Commit

Permalink
fix(shirelang): add exception handling for LlmProvider streaming output
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 26, 2024
1 parent da44e85 commit a8272b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ class ShireConversationService(val project: Project) {
val finalPrompt = prompt.toString()
if (consoleView != null) {
runBlocking {
LlmProvider.provider(project)
?.stream(finalPrompt, "", true)
?.collect {
consoleView.print(it, ConsoleViewContentType.NORMAL_OUTPUT)
}
try {
LlmProvider.provider(project)
?.stream(finalPrompt, "", true)
?.collect {
consoleView.print(it, ConsoleViewContentType.NORMAL_OUTPUT)
}
} catch (e: Exception) {
consoleView.print(e.message ?: "Error", ConsoleViewContentType.ERROR_OUTPUT)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ class ShireProcessProcessor(val project: Project) {
if (consoleView == null) return

runBlocking {
LlmProvider.provider(project)?.stream(result.shireOutput, "Shirelang", true)
?.collect {
consoleView.print(it, ConsoleViewContentType.NORMAL_OUTPUT)
}
try {
LlmProvider.provider(project)?.stream(result.shireOutput, "Shirelang", true)?.collect {
consoleView.print(it, ConsoleViewContentType.NORMAL_OUTPUT)
}
} catch (e: Exception) {
consoleView.print(e.message ?: "Error", ConsoleViewContentType.ERROR_OUTPUT)
}
}
} else {
if (result.nextJob == null) return
Expand Down

0 comments on commit a8272b2

Please sign in to comment.