Building an AI Chat Starter Kit for CMP: ~20 Lines from Empty Screen to ChatGPT-Quality Streaming
The point isn't either lib in isolation. The point is they're built to wire together so you get a ChatGPT-quality streaming chat UI in ~20 lines on every CMP target.
重點摘要
Two open-sourced Compose Multiplatform libraries: prompt-bar and llm-typewriter.
Prompt-bar handles composing, mentions, attachments, model selection, and send/stop states.
Llm-typewriter streams Flow<String> tokens with live Markdown and progressive syntax highlighting.
The author describes two open-sourced Compose Multiplatform libraries that together form an AI chat starter kit for Android, iOS, Desktop, and Web. prompt-bar provides the composer UI and state for slash commands, @ mentions, attachments, templates, and a morphing Send/Stop button. llm-typewriter renders streamed LLM output from a Flow<String>, supporting live Markdown, progressive syntax highlighting, tap-to-skip, and graceful stopping. The article explains that the real value is in combining both pieces so developers can build a polished, ChatGPT-like streaming chat experience in roughly 20 lines of code across CMP targets.
为 CMP 构建 AI 聊天起手包:用约 20 行代码从空白界面做到 ChatGPT 级流式体验
关键不在于单个库本身,而在于它们被设计成可以无缝衔接,让你在每个 CMP 目标平台上都能用约 20 行代码做出 ChatGPT 级聊天 UI。
重點摘要
开源了两个 Compose Multiplatform 库:prompt-bar 和 llm-typewriter。
prompt-bar 负责输入、提及、附件、模型选择以及发送/停止状态。
llm-typewriter 以 Flow<String> 流式渲染,支持实时 Markdown 和渐进式语法高亮。
作者开源了两个可以组合使用的 Compose Multiplatform 库,为 Android、iOS、Desktop 和 Web 提供 AI 聊天起手包。prompt-bar 负责聊天输入器和状态管理,支持斜杠命令、@ 提及、附件、模板、模型选择,以及会随状态变化的 Send/Stop 按钮;llm-typewriter 则直接消费 LLM SDK 输出的 Flow<String>,实现实时 Markdown、渐进式语法高亮、点击跳过和中途停止。文章强调,这两者结合后,开发者只需约 20 行代码,就能在各个 CMP 平台上搭出接近 ChatGPT 的流式聊天体验。
為 CMP 打造 AI 聊天起手式:用約 20 行程式碼從空白畫面做到 ChatGPT 級串流體驗
重點不在單一函式庫,而是兩者能彼此串接,讓你在每個 CMP 目標平台上都能用約 20 行程式碼做出 ChatGPT 級串流聊天介面。
重點摘要
開源兩個 Compose Multiplatform 函式庫:prompt-bar 與 llm-typewriter。
prompt-bar 負責輸入、提及、附件、模型選擇與送出/停止狀態。
llm-typewriter 以 Flow<String> 串流渲染,支援即時 Markdown 與逐步語法高亮。
作者開源了兩個可搭配使用的 Compose Multiplatform 函式庫,作為 Android、iOS、Desktop 與 Web 的 AI 聊天起手式。prompt-bar 提供聊天輸入器與狀態管理,涵蓋斜線指令、@ 提及、附件、模板、模型選擇,以及會依狀態變形的 Send/Stop 按鈕;llm-typewriter 則直接接收來自 LLM SDK 的 Flow<String> 串流,實作即時 Markdown、逐步語法高亮、點擊跳過與中止串流。文章強調,兩者結合後,才能用約 20 行程式碼做出接近 ChatGPT 的串流聊天介面。