{#- chirp-ui: Streaming and AI components For LLM Playground, RAG demo, and SSE-driven UIs. Works with htmx SSE and event delegation for copy buttons. Usage: {% from "chirpui/streaming.html" import streaming_block, copy_btn, prose %} {% call streaming_block(streaming=true) %} Content or thinking... {% end %} {% call copy_btn(text="Copy", copy_text=answer_text) %}
{{ content | markdown | safe }}
-#} {% def streaming_bubble(role="assistant", streaming=true, sse_swap_target=false, sse_connect=none, sse_close="done", cls="") %} {% set role_valid = role | validate_variant_block("message_bubble", default="assistant") %} {% set role_class = " chirpui-message-bubble--" ~ role_valid if role_valid != "default" else "" %}
{% slot %} {% if streaming %} {% end %}
{% end %} {% def streaming_block(streaming=false, sse_swap_target=false, cls="") %}
{% slot %} {% if streaming %} {% end %}
{% end %} {% def copy_btn(label="Copy", copy_text="", cls="") %} {% end %} {% def model_card(title, badge=none, footer=none, cls="", sse_connect=none, sse_close="done", sse_streaming=false) %}
{{ title }} {% if badge %} {{ badge }} {% end %}
{% if sse_streaming %}
{% slot %}
{% else %} {% slot %} {% end %}
{% if footer %} {% end %}
{% end %}