← ClaudeAtlas

streaming-llm-responseslisted

Implement real-time streaming UI patterns for AI chat applications. Use when adding response lifecycle handlers, progress indicators, client effects, or thread state synchronization. Covers onResponseStart/End, onEffect, ProgressUpdateEvent, and client tools. NOT when building basic chat without real-time feedback.
aiskillstore/marketplace · ★ 329 · AI & Automation · score 79
Install: claude install-skill aiskillstore/marketplace
# Streaming LLM Responses Build responsive, real-time chat interfaces with streaming feedback. ## Quick Start ```typescript import { useChatKit } from "@openai/chatkit-react"; const chatkit = useChatKit({ api: { url: API_URL, domainKey: DOMAIN_KEY }, onResponseStart: () => setIsResponding(true), onResponseEnd: () => setIsResponding(false), onEffect: ({ name, data }) => { if (name === "update_status") updateUI(data); }, }); ``` --- ## Response Lifecycle ``` User sends message ↓ onResponseStart() fires ↓ [Streaming: tokens arrive, ProgressUpdateEvents shown] ↓ onResponseEnd() fires ↓ UI unlocks, ready for next interaction ``` --- ## Core Patterns ### 1. Response Lifecycle Handlers Lock UI during AI response to prevent race conditions: ```typescript function ChatWithLifecycle() { const [isResponding, setIsResponding] = useState(false); const lockInteraction = useAppStore((s) => s.lockInteraction); const unlockInteraction = useAppStore((s) => s.unlockInteraction); const chatkit = useChatKit({ api: { url: API_URL, domainKey: DOMAIN_KEY }, onResponseStart: () => { setIsResponding(true); lockInteraction(); // Disable map/canvas/form interactions }, onResponseEnd: () => { setIsResponding(false); unlockInteraction(); }, onError: ({ error }) => { console.error("ChatKit error:", error); setIsResponding(false