Install
$ agentstack add skill-deeleeramone-pywry-chat ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Chat Component - Reference Guide
> Read this before creating chat widgets.
Overview
The chat component provides a full-featured conversational UI with:
- Message rendering with inline markdown
- Streaming responses with token-by-token display
- Stop-generation (cancel in-flight LLM responses)
- Thread management (create, switch, delete)
- Slash command palette (type
/to see commands) - Settings panel (model, temperature, system prompt)
- LLM provider adapters (OpenAI, Anthropic, custom callback)
Quick Start
Via MCP Tool
{
"name": "create_chat_widget",
"arguments": {
"title": "AI Assistant",
"model": "gpt-4",
"system_prompt": "You are a helpful assistant.",
"streaming": true,
"provider": "openai"
}
}
Via Python
from pywry import App
from pywry.chat import ChatConfig, ChatWidgetConfig
app = App()
config = ChatWidgetConfig(
title="AI Chat",
height=600,
chat=ChatConfig(
system_prompt="You are helpful.",
model="gpt-4",
streaming=True,
provider="openai",
),
)
# Widget creation handled by MCP or directly via app.show()
MCP Tools
createchatwidget
Creates a chat widget. Returns {widget_id, thread_id}.
| Parameter | Type | Default | Description | |----------------|---------|----------|--------------------------------| | title | string | "Chat" | Window title | | height | integer | 600 | Window height | | systemprompt | string | "" | System prompt for LLM | | model | string | "gpt-4" | Model name | | temperature | number | 0.7 | Sampling temperature (0-2) | | maxtokens | integer | 4096 | Max tokens per response | | streaming | boolean | true | Enable streaming | | persist | boolean | false | Persist threads in ChatStore | | provider | string | — | "openai", "anthropic", "callback" | | showsidebar | boolean | true | Show thread sidebar | | slashcommands | array | — | Custom slash commands |
chatsendmessage
Send a user message. Returns {message_id, thread_id, sent}.
chatstopgeneration
Stop an in-flight generation. Idempotent. Returns partial content.
chatmanagethread
Thread CRUD: create, switch, delete, rename, list.
chatregistercommand
Register a slash command at runtime.
chatgethistory
Paginated conversation history with cursor (before_id).
chatupdatesettings
Update model, temperature, system prompt, etc.
chatsettyping
Show/hide the typing indicator.
Event Contract
Incoming Events (Python → Frontend)
| Event | Payload | |---------------------------|--------------------------------------------| | chat:assistant-message | {messageId, text, threadId} | | chat:stream-chunk | {chunk, messageId, threadId, done} | | chat:typing-indicator | {typing, threadId} | | chat:switch-thread | {threadId} | | chat:update-thread-list | {threads: [{thread_id, title}]} | | chat:clear | {} | | chat:register-command | {name, description} | | chat:update-settings | {model, temperature, system_prompt} | | chat:state-response | {messages, threads, settings, activeThreadId} | | chat:generation-stopped | {messageId, threadId, partialContent} |
Outgoing Events (Frontend → Python)
| Event | Payload | |--------------------------|---------------------------------------------| | chat:user-message | {text, threadId, timestamp} | | chat:slash-command | {command, args, threadId} | | chat:thread-create | {title} | | chat:thread-switch | {threadId} | | chat:thread-delete | {threadId} | | chat:settings-change | {key, value} | | chat:request-history | {threadId, limit} | | chat:stop-generation | {threadId, messageId} | | chat:request-state | {} |
Stop-Generation Mechanics
- User clicks Stop button → frontend immediately re-enables UI
chat:stop-generationsent to backend- Backend sets
cancel_eventonGenerationHandle - LLM provider checks
cancel_event.is_set()between chunks - Provider raises
GenerationCancelledError→ partial content saved - Backend emits
chat:generation-stoppedwith partial content - Frontend marks message as "(stopped)"
The UI never waits for backend confirmation — recovery is instant.
Default Slash Commands
| Command | Description | |-----------|----------------------------| | /clear | Clear conversation | | /export | Export chat history | | /model | Switch model | | /system | Change system prompt |
Register custom commands via chat_register_command tool or ChatConfig.slash_commands list.
LLM Providers
OpenAI
{"provider": "openai"}
Requires openai package and OPENAI_API_KEY environment variable.
Anthropic
{"provider": "anthropic"}
Requires anthropic package and ANTHROPIC_API_KEY environment variable.
Custom Callback
from pywry.chat.providers.callback import CallbackProvider
provider = CallbackProvider(
prompt_fn=my_prompt, # (session_id, content_blocks, cancel_event) → AsyncIterator[SessionUpdate]
)
Safety Constants
| Constant | Value | Purpose | |--------------------------|----------|----------------------------------| | MAXRENDEREDMESSAGES | 200 | DOM cap for performance | | MAXCONTENTLENGTH | 100,000 | Per-message content limit | | MAXMESSAGESPERTHREAD | 1,000 | Eviction threshold | | STREAMTIMEOUTSECONDS | 30 | Max silence before timeout | | SENDCOOLDOWNMS | 1,000 | Input rate limit | | GENERATIONHANDLE_TTL | 300 | Auto-expire stale handles |
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: deeleeramone
- Source: deeleeramone/PyWry
- License: Apache-2.0
- Homepage: https://deeleeramone.github.io/PyWry/
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.