Skip to content

Commit 9c096c9

Browse files
authored
[examples] use Markdown renderer for agent response text in demo app (#1197)
Uses https://github.com/mikepenz/multiplatform-markdown-renderer for displaying agent response text <img width="1039" height="802" alt="Screenshot 2025-11-28 at 10 59 04" src="https://github.com/user-attachments/assets/1b5e336b-9c6d-443d-9162-cae077f53c21" /> cc @mikepenz :)
1 parent 9d65c04 commit 9c096c9

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

examples/demo-compose-app/commonApp/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ kotlin {
4949
implementation(libs.koog.prompt.executor.llms.all)
5050
implementation(libs.kotlinx.coroutines.core)
5151
implementation(libs.kotlinx.datetime)
52+
implementation(libs.markdown.renderer)
5253
implementation(libs.kotlinx.serialization.core)
5354
implementation(libs.kotlinx.serialization.json)
5455
implementation(project.dependencies.platform(libs.koin.bom))

examples/demo-compose-app/commonApp/src/commonMain/kotlin/com/jetbrains/example/koog/compose/screens/agentdemo/AgentDemoScreen.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ import androidx.compose.ui.text.input.ImeAction
5151
import androidx.compose.ui.unit.dp
5252
import com.jetbrains.example.koog.compose.theme.AppDimension
5353
import com.jetbrains.example.koog.compose.theme.AppTheme
54+
import com.mikepenz.markdown.m3.Markdown
55+
import com.mikepenz.markdown.m3.markdownColor
56+
import com.mikepenz.markdown.m3.markdownTypography
5457
import org.jetbrains.compose.ui.tooling.preview.Preview
5558

5659
@Composable
@@ -202,10 +205,10 @@ private fun AgentMessageBubble(text: String) {
202205
.background(MaterialTheme.colorScheme.primaryContainer)
203206
.padding(AppDimension.spacingMedium)
204207
) {
205-
Text(
206-
text = text,
207-
color = MaterialTheme.colorScheme.onPrimaryContainer,
208-
style = MaterialTheme.typography.bodyLarge
208+
Markdown(
209+
content = text,
210+
colors = markdownColor(text = MaterialTheme.colorScheme.onPrimaryContainer),
211+
typography = markdownTypography(text = MaterialTheme.typography.bodyLarge)
209212
)
210213
}
211214
}

examples/demo-compose-app/gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ kotlinx-datetime = "0.7.1-0.6.x-compat"
1515
kotlinx-serialization = "1.9.0"
1616
ktlint = "14.0.1"
1717
ktor = "3.3.2"
18+
markdown-renderer = "0.38.1"
1819

1920
[libraries]
2021
androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
@@ -36,6 +37,7 @@ ktor-client-apache5 = { module = "io.ktor:ktor-client-apache5" }
3637
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin" }
3738
ktor-client-js = { module = "io.ktor:ktor-client-js" }
3839
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp" }
40+
markdown-renderer = { module = "com.mikepenz:multiplatform-markdown-renderer-m3", version.ref = "markdown-renderer" }
3941

4042
[plugins]
4143
android-application = { id = "com.android.application", version.ref = "agp" }

0 commit comments

Comments
 (0)