chatkit-streaming
БесплатноБез исполняемых скриптовНе проверенImplements real-time streaming UI patterns for ChatKit applications. This skill should be used when adding response lifecycle management, progress indicators…
от mjunaidca★ 27 звёзд на GitHubОб этом скилле
ChatKit Streaming Skill
Overview
This skill provides patterns for building responsive, real-time ChatKit interfaces. It covers the streaming layer between basic integration and full interactive widgets - making the UI feel alive during AI responses.
Core Concepts
Response Lifecycle
ChatKit streams responses in real-time. The lifecycle:
User sends message
↓
onResponseStart() fires
↓
[Streaming: tokens arrive, ProgressUpdateEvents shown]
↓
onResponseEnd() fires
↓
UI unlocks, ready for next interaction
Client Effects vs Client Tools
| Type | Direction | Response Required | Use Case |
|---|---|---|---|
| Client Effect | Server → Client | No (fire-and-forget) | Update UI state, show notifications |
| Client Tool | Server → Client → Server | Yes (return value) | Get client state for AI decision |
Implementation Patterns
Pattern 1: Response Lifecycle Handlers
When: Lock UI during AI response, show loading states, prevent race conditions
Frontend Implementation:
import { useChatKit } from "@openai/chatkit-react";
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();
},
onReady: () => {
console.log("ChatKit initialized");
},
onError: ({ error }) => {
console.error("ChatKit error:", error);
setIsResponding(false);
unlockInteraction();
},
});
return (
<div>
{isResponding && <LoadingOverlay />}
<ChatKit control={chatkit.control} />
</div>
);
}
Evidence: metro-map/frontend/src/components/ChatKitPanel.tsx:205-210
Pattern 2: Client Effects (Fire-and-Forget)
When: Server needs to update client UI without expecting a response
Backend - Streaming Effects:
from chatkit.types import ClientEffectEvent
async def respond(self, thread, item, context):
# ... agent processing ...
# Fire client effect to update UI
yield ClientEffectEvent(
name="update_cat_status",
data={
"state": {"energy": 80, "happiness": 90},
"flash": "Cat is now happy!"
}
)
# Another effect - speech bubble
yield ClientEffectEvent(
name="cat_say",
data={"message": "Meow!"}
)
Frontend - Handling Effects:
const chatkit = useChatKit({
api: { url: API_URL, domainKey: DOMAIN_KEY },
onEffect: ({ name, data }) => {
switch (name) {
case "update_cat_status":
const catState = data.state as CatStatePayload;
applyCatUpdate(catState);
if (data.flash) {
setFlashMessage(data.flash as string);
}
break;
case "cat_say":
setSpeech({ message: String(data.message) });
break;
case "location_select_mode":
setLocationSelectLineId(data.lineId as string);
break;
case "add_station":
clearLocationSelectMode();
if (data.map) setMap(data.map as MetroMap);
if (data.stationId) {
requestAnimationFrame(() => focusStation(data.stationId));
}
break;
}
},
});
Evidence:
cat-lounge/backend/app/cat_agent.py(server-side effects)cat-lounge/frontend/src/components/ChatKitPanel.tsx:86-103(frontend handler)metro-map/frontend/src/components/ChatKitPanel.tsx:130-153
Pattern 3: Progress Updates
When: Show "Searching...", "Loading...", "Analyzing..." during long operations
Backend - Streaming Progress:
from chatkit.types import ProgressUpdateEvent
@function_tool
async def search_articles(ctx: AgentContext, query: str) -> str:
"""Search for articles matching the query."""
# Show progress to user
yield ProgressUpdateEvent(message="Searching articles...")
results = await article_store.search(query)
yield ProgressUpdateEvent(message=f"Found {len(results)} articles...")
# Process results
for i, article in enumerate(results):
if i % 5 == 0:
yield ProgressUpdateEvent(
message=f"Processing article {i+1}/{len(results)}..."
)
# ... process article
return format_results(results)
Evidence:
news-guide/backend/app/agents/news_agent.py(search tools with progress)metro-map/backend/app/agents/metro_map_agent.py(get_map progress)
Pattern 4: Thread Lifecycle Events
When: Track thread changes, persist thread state, update UI on thread switch
Frontend Implementation:
co
Установить chatkit-streaming в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл chatkit-streaming?
Implements real-time streaming UI patterns for ChatKit applications. This skill should be used when adding response lifecycle management, progress indicators, client effects, and thread state synchronization. Covers onResponseStart/End, onEffect, ProgressUpdateEvent, and thread lifecycle events.
Как установить скилл chatkit-streaming?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл chatkit-streaming запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic