Skip to content

Commit

Permalink
Addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
laileni-aws committed Apr 23, 2024
1 parent 7cb364f commit ac2b63d
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ class ChatPromptHandler(private val telemetryHelper: TelemetryHelper) {
private var requestId: String = ""
private var statusCode: Int = 0

companion object {
private val CODE_BLOCK_PATTERN = Regex("<pre>\\s*<code")
}

private fun countTotalNumberOfCodeBlocks(message: StringBuilder): Int {
if (message.isEmpty()) {
return 0
}
val htmlInString = convertMarkdownToHTML(message.toString())
val patternOfCodeBlock = Regex("<pre>\\s*<code")
return patternOfCodeBlock.findAll(htmlInString).count()
return CODE_BLOCK_PATTERN.findAll(htmlInString).count()
}

fun handle(
Expand Down

0 comments on commit ac2b63d

Please sign in to comment.