pywry.chat¶
ACP-native chat system for PyWry — models, session primitives, update types, artifacts, providers, and the ChatManager orchestrator.
Manager¶
pywry.chat.manager.ChatManager
¶
ChatManager(provider: Any = None, handler: HandlerFunc | None = None, *, system_prompt: str = '', model: str = '', temperature: float = 0.7, welcome_message: str = '', settings: Sequence[SettingsItem] | None = None, slash_commands: Sequence[Any] | None = None, on_slash_command: Callable[..., Any] | None = None, on_settings_change: Callable[..., Any] | None = None, show_sidebar: bool = True, show_settings: bool = True, toolbar_width: str = '380px', toolbar_min_width: str = '280px', collapsible: bool = True, resizable: bool = True, include_plotly: bool = False, include_aggrid: bool = False, aggrid_theme: str = 'alpine', enable_context: bool = False, enable_file_attach: bool = False, file_accept_types: list[str] | None = None, context_allowed_roots: list[str] | None = None)
ACP-native orchestrator for the PyWry chat component.
Handles event wiring, thread management, streaming, cancellation,
and state synchronization. Accepts either a ChatProvider instance
(ACP session lifecycle) or a handler function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
ChatProvider | None
|
ACP-conformant provider instance. |
None
|
handler
|
callable | None
|
Handler function |
None
|
system_prompt
|
str
|
System prompt prepended to every request. |
''
|
model
|
str
|
Model identifier passed to handler via context. |
''
|
temperature
|
float
|
Temperature passed to handler via context. |
0.7
|
welcome_message
|
str
|
Markdown message sent when the chat initializes. |
''
|
settings
|
list[SettingsItem] | None
|
Settings items for the gear dropdown. |
None
|
on_settings_change
|
callable | None
|
Callback |
None
|
show_sidebar
|
bool
|
Show the conversation picker. |
True
|
show_settings
|
bool
|
Show the gear icon. |
True
|
toolbar_width
|
str
|
CSS width for the chat toolbar. |
'380px'
|
toolbar_min_width
|
str
|
CSS min-width for the chat toolbar. |
'280px'
|
collapsible
|
bool
|
Whether the toolbar is collapsible. |
True
|
resizable
|
bool
|
Whether the toolbar is resizable. |
True
|
include_plotly
|
bool
|
Include Plotly.js eagerly. |
False
|
include_aggrid
|
bool
|
Include AG Grid eagerly. |
False
|
aggrid_theme
|
str
|
AG Grid theme name. |
'alpine'
|
enable_context
|
bool
|
Enable @-mention widget references. |
False
|
enable_file_attach
|
bool
|
Enable file attachment button. |
False
|
file_accept_types
|
list[str] | None
|
Allowed file extensions (required when |
None
|
context_allowed_roots
|
list[str] | None
|
Restrict file attachments to these directories. |
None
|
Attributes¶
CONTEXT_TOOL
class-attribute
¶
CONTEXT_TOOL: dict[str, Any] = {'type': 'function', 'function': {'name': 'get_context', 'description': 'Retrieve the full content of an attached file or widget. Call this when you need to read, analyze, or reference an attachment the user has provided.', 'parameters': {'type': 'object', 'properties': {'name': {'type': 'string', 'description': 'The attachment name.'}}, 'required': ['name']}}}
_slash_commands
instance-attribute
¶
_context_allowed_roots
instance-attribute
¶
_context_allowed_roots = [(str(resolve())) for r in context_allowed_roots] if context_allowed_roots else None
_settings_values
instance-attribute
¶
_settings_values: dict[str, Any] = {(id): (value) for s in (_settings_items) if type != 'separator'}
Functions¶
register_context_source
¶
Register a live component as an @-mentionable context source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_id
|
str
|
Unique ID of the component. |
required |
name
|
str
|
Human-readable label shown in the popup. |
required |
bind
¶
Bind to a widget after app.show().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
widget
|
Any
|
The widget instance returned by |
required |
toolbar
¶
toolbar(*, position: Literal['header', 'footer', 'top', 'bottom', 'left', 'right', 'inside'] = 'right') -> Any
Build a Toolbar containing the chat panel.
Returns:
| Type | Description |
|---|---|
Any
|
A |
callbacks
¶
Return the callbacks dict for app.show(callbacks=...).
Returns:
| Type | Description |
|---|---|
dict[str, Callable]
|
Event handler mappings for all chat events. |
send_message
¶
Send a programmatic assistant message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Message text. |
required |
thread_id
|
str | None
|
Target thread. Defaults to active thread. |
None
|
_emit_fire
¶
Fire-and-forget emit for high-frequency streaming.
_inject_aggrid_assets
¶
Lazy-inject AG Grid JS/CSS on first table artifact.
_inject_plotly_assets
¶
Lazy-inject Plotly JS on first plotly artifact.
_inject_tradingview_assets
¶
Lazy-inject TradingView lightweight-charts on first TV artifact.
_dispatch_artifact
¶
Dispatch an artifact to the frontend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
_ArtifactBase
|
Concrete artifact instance. |
required |
message_id
|
str
|
Current assistant message ID. |
required |
thread_id
|
str
|
Current thread ID. |
required |
_resolve_widget_attachment
¶
_resolve_widget_attachment(widget_id: str, content: str | None = None, name: str | None = None) -> Attachment | None
Create an Attachment for a widget/component reference.
The resulting attachment always carries an explicit
widget_id: <id> line so an LLM agent reading the @-context
can use it directly in any tool call that requires a widget_id
(notably the MCP tvchart_* family). Any payload returned
by the JS-side getData() is appended after the id header.
_auto_attach_context_sources
¶
Append every registered context source the user didn't @-mention.
A widget registered with meth:
register_context_source is part
of the chat's permanent @context: every user message carries
an attachment for it whose content begins with widget_id: <id>.
That guarantees an LLM agent always has the routing information
for the chat's components without the user having to repeat
@<name> on every turn.
Already-resolved attachments take precedence — explicit mentions
keep whatever payload the frontend's getData() returned.
_resolve_attachments
¶
Resolve raw attachment dicts into Attachment objects.
_get_context_sources
¶
List available context sources for the @-mention popup.
_dispatch_text_update
¶
_dispatch_text_update(update: ThinkingUpdate | StatusUpdate | CitationUpdate, state: _StreamState, thread_id: str) -> None
Dispatch thinking, status, or citation updates.
_dispatch_config_update
¶
_dispatch_config_update(update: CommandsUpdate | ConfigOptionUpdate | ModeUpdate, state: _StreamState) -> None
Dispatch commands, config, or mode updates.
_dispatch_tool_call_update
¶
_dispatch_tool_call_update(update: ToolCallUpdate, state: _StreamState, thread_id: str) -> None
Dispatch a tool-call start OR a tool-result to the UI.
_dispatch_session_update
¶
_dispatch_session_update(update: Any, state: _StreamState, thread_id: str, ctx: ChatContext | None) -> None
Dispatch a single SessionUpdate to the frontend.
_process_handler_item
¶
_process_handler_item(item: Any, state: _StreamState, thread_id: str, ctx: ChatContext | None) -> None
Dispatch a handler yield item.
Handles plain strings, SessionUpdate objects, and artifacts.
_buffer_text
¶
Add text to buffer, auto-flush on threshold.
_finalize_stream
¶
Flush remaining buffer and send stream-done events.
_handle_cancel
¶
Handle stream cancellation.
_handle_stream
¶
_handle_stream(gen: Any, message_id: str, thread_id: str, cancel: Event, *, ctx: ChatContext | None = None) -> None
Stream from a sync generator.
_handle_async_stream
async
¶
_handle_async_stream(agen: Any, message_id: str, thread_id: str, cancel: Event, *, ctx: ChatContext | None = None) -> None
Stream from an async generator.
_inject_context
¶
_inject_context(messages: list[MessageDict], ctx: ChatContext, message_id: str, thread_id: str) -> list[MessageDict]
Inject attachment context into messages.
_dispatch_handler_result
¶
_dispatch_handler_result(result: Any, message_id: str, thread_id: str, cancel: Event, ctx: ChatContext) -> None
Route handler return value to processing path.
_handle_complete
¶
Send a complete (non-streamed) assistant message.
_run_handler
¶
_run_handler(messages: list[MessageDict], ctx: ChatContext, message_id: str, thread_id: str, cancel: Event) -> None
Execute the handler in a background thread.
_on_user_message
¶
Handle incoming user message.
_run_provider
¶
_run_provider(messages: list[MessageDict], ctx: ChatContext, message_id: str, thread_id: str, cancel: Event) -> None
Execute the ACP provider prompt in a background thread.
_on_stop_generation
¶
Cancel active generation.
_truncate_thread_at
¶
_truncate_thread_at(thread_id: str, message_id: str, *, keep_target: bool) -> tuple[list[MessageDict], list[str]]
Truncate a thread's history at the message with message_id.
Returns a tuple (removed_messages, removed_ids). When
keep_target is True the message itself is retained and only
messages after it are removed; when False the target message and
everything after it are removed.
_truncate_provider_state
¶
Best-effort: align the provider's persisted history with the UI.
For LangGraph-backed providers (DeepagentProvider) we delete the thread state from the checkpointer so the next prompt rebuilds from a fresh state. The next user message gets re-sent to the agent with the full surviving history via the ChatManager flow.
_on_edit_message
¶
Edit a previously-sent user message and regenerate from there.
_on_resend_from
¶
Re-run generation from a specific user message in the thread.
The target user message stays visible — only the assistant reply (and any subsequent turns) are dropped and regenerated. Previous behaviour also removed the user bubble itself, which looked like the message had been erased.
_on_todo_clear
¶
Handle user clearing the plan/todo list.
_on_input_response
¶
Handle user response to an input-required prompt.
_on_slash_command_event
¶
Handle slash command from frontend.
_on_thread_create
¶
Create a new thread.
_on_thread_switch
¶
Switch to an existing thread.
_on_thread_delete
¶
Delete a thread.
_on_thread_rename
¶
Rename a thread.
_on_settings_change_event
¶
Handle settings change.
_on_request_state
¶
Respond to initialization request from frontend JS.
_build_thread_list
¶
Build thread list dicts for the frontend.
pywry.chat.manager.ChatContext
dataclass
¶
ChatContext(thread_id: str = '', message_id: str = '', settings: dict[str, Any] = dict(), cancel_event: Event = Event(), system_prompt: str = '', model: str = '', temperature: float = 0.7, attachments: list[Attachment] = list())
Context object passed to handler functions.
Attributes:
| Name | Type | Description |
|---|---|---|
thread_id |
str
|
Active thread ID. |
message_id |
str
|
The assistant message ID being generated. |
settings |
dict[str, Any]
|
Current settings values. |
cancel_event |
Event
|
Set when the user clicks Stop. |
system_prompt |
str
|
System prompt configured for the chat. |
model |
str
|
Model name configured for the chat. |
temperature |
float
|
Temperature configured for the chat. |
attachments |
list[Attachment]
|
Resolved context attachments for the current message. |
Attributes¶
settings
class-attribute
instance-attribute
¶
cancel_event
class-attribute
instance-attribute
¶
attachments
class-attribute
instance-attribute
¶
attachment_summary
property
¶
One-line summary of attached context for system/user prompts.
Returns:
| Type | Description |
|---|---|
str
|
Summary line, or empty string when no attachments. |
context_text
property
¶
Pre-formatted attachment content ready to inject into prompts.
Returns:
| Type | Description |
|---|---|
str
|
Multi-block attachment context, or empty string. |
_input_event
class-attribute
instance-attribute
¶
_input_response
class-attribute
instance-attribute
¶
Functions¶
get_attachment
¶
Retrieve attachment content or path by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Attachment name, with or without a leading |
required |
Returns:
| Type | Description |
|---|---|
str
|
Attachment path or content, or a not-found message. |
wait_for_input
¶
Block until the user provides input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float | None
|
Maximum seconds to wait. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
User-supplied input, or empty string on cancellation/timeout. |
ACP Session Updates¶
pywry.chat.updates.AgentMessageUpdate
¶
pywry.chat.updates.StatusUpdate
¶
pywry.chat.updates.ThinkingUpdate
¶
pywry.chat.updates.CitationUpdate
¶
pywry.chat.updates.ToolCallUpdate
¶
pywry.chat.updates.PlanUpdate
¶
pywry.chat.updates.CommandsUpdate
¶
Bases: BaseModel
Available slash commands from the agent.
Attributes¶
session_update
class-attribute
instance-attribute
¶
session_update: Literal['available_commands'] = Field(default='available_commands', alias='sessionUpdate')
commands
class-attribute
instance-attribute
¶
commands: list[ACPCommand] = Field(default_factory=list)
pywry.chat.updates.ConfigOptionUpdate
¶
Bases: BaseModel
Config option state change.
Attributes¶
session_update
class-attribute
instance-attribute
¶
options
class-attribute
instance-attribute
¶
options: list[SessionConfigOption] = Field(default_factory=list)
pywry.chat.updates.ModeUpdate
¶
Bases: BaseModel
Agent mode change notification.
Attributes¶
session_update
class-attribute
instance-attribute
¶
current_mode_id
class-attribute
instance-attribute
¶
available_modes
class-attribute
instance-attribute
¶
available_modes: list[SessionMode] = Field(default_factory=list, alias='availableModes')
pywry.chat.updates.PermissionRequestUpdate
¶
Bases: BaseModel
Agent requests user permission before tool execution.
Attributes¶
session_update
class-attribute
instance-attribute
¶
session_update: Literal['permission_request'] = Field(default='permission_request', alias='sessionUpdate')
tool_call_id
class-attribute
instance-attribute
¶
options
class-attribute
instance-attribute
¶
request_id
class-attribute
instance-attribute
¶
pywry.chat.updates.ArtifactUpdate
¶
Artifacts¶
pywry.chat.artifacts.CodeArtifact
¶
Bases: _ArtifactBase
Code snippet rendered with syntax highlighting.
Attributes:
| Name | Type | Description |
|---|---|---|
artifact_type |
str
|
Fixed to |
content |
str
|
Source code or text snippet. |
language |
str
|
Language hint for syntax highlighting. |
Attributes¶
pywry.chat.artifacts.MarkdownArtifact
¶
Bases: _ArtifactBase
Markdown content rendered as formatted HTML.
Attributes:
| Name | Type | Description |
|---|---|---|
artifact_type |
str
|
Fixed to |
content |
str
|
Markdown source. |
Attributes¶
pywry.chat.artifacts.HtmlArtifact
¶
Bases: _ArtifactBase
Raw HTML rendered in a sandboxed container.
Attributes:
| Name | Type | Description |
|---|---|---|
artifact_type |
str
|
Fixed to |
content |
str
|
Raw HTML content. |
Attributes¶
pywry.chat.artifacts.TableArtifact
¶
Bases: _ArtifactBase
Tabular data rendered as an AG Grid widget.
Accepts the same data formats as normalize_data() in grid.py:
pandas DataFrame, list of dicts, dict of lists, or single dict.
Attributes:
| Name | Type | Description |
|---|---|---|
artifact_type |
str
|
Fixed to |
data |
list[dict[str, Any]] | dict[str, Any]
|
Table rows or source object to normalize. |
column_defs |
list[dict[str, Any]] | None
|
Optional AG Grid column definitions. |
grid_options |
dict[str, Any] | None
|
Optional AG Grid configuration overrides. |
height |
str
|
CSS height for the table container. |
pywry.chat.artifacts.PlotlyArtifact
¶
Bases: _ArtifactBase
Plotly chart rendered as an interactive widget.
figure accepts a standard Plotly figure dict:
{"data": [...traces], "layout": {...}, "config": {...}}.
Attributes:
| Name | Type | Description |
|---|---|---|
artifact_type |
str
|
Fixed to |
figure |
dict[str, Any]
|
Plotly figure payload. |
height |
str
|
CSS height for the chart container. |
Attributes¶
pywry.chat.artifacts.ImageArtifact
¶
Bases: _ArtifactBase
Image rendered as an <img> element.
url can be a data URI (data:image/png;base64,...) or an
HTTP(S) URL.
Attributes:
| Name | Type | Description |
|---|---|---|
artifact_type |
str
|
Fixed to |
url |
str
|
Image URL or data URI. |
alt |
str
|
Alternate text. |
Attributes¶
Functions¶
_block_dangerous_schemes
classmethod
¶
Reject javascript: URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str
|
Candidate image URL. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The original URL when safe. |
Raises:
| Type | Description |
|---|---|
ValueError
|
When the URL uses the |
pywry.chat.artifacts.JsonArtifact
¶
Bases: _ArtifactBase
Structured data rendered as a collapsible JSON tree.
Attributes:
| Name | Type | Description |
|---|---|---|
artifact_type |
str
|
Fixed to |
data |
Any
|
Arbitrary JSON-serializable payload. |
Attributes¶
pywry.chat.artifacts.TradingViewArtifact
¶
Bases: _ArtifactBase
Interactive financial chart via TradingView lightweight-charts.
Supports candlestick, line, area, bar, baseline, and histogram series. Multiple series can be overlaid on a single chart.
Attributes:
| Name | Type | Description |
|---|---|---|
artifact_type |
str
|
Fixed to |
series |
list[TradingViewSeries]
|
One or more data series to render. |
options |
dict[str, Any]
|
Chart-level options passed to |
height |
str
|
CSS height for the chart container. |
Examples:
>>> yield TradingViewArtifact(
... title="AAPL Daily",
... series=[
... TradingViewSeries(
... type="candlestick",
... data=[
... {
... "time": "2024-01-02",
... "open": 185.5,
... "high": 186.1,
... "low": 184.0,
... "close": 185.6,
... },
... ],
... ),
... ],
... height="500px",
... )
Attributes¶
artifact_type
class-attribute
instance-attribute
¶
series
class-attribute
instance-attribute
¶
series: list[TradingViewSeries] = Field(default_factory=list)
pywry.chat.artifacts.TradingViewSeries
¶
Bases: BaseModel
A single data series on a TradingView chart.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Series type — |
data |
list[dict[str, Any]]
|
Data points. For candlestick:
|
options |
dict[str, Any]
|
Series-level options (colors, line width, price format, etc.). |
markers |
list[dict[str, Any]] | None
|
Optional markers (buy/sell signals, annotations). |
pywry.chat.artifacts.AppArtifact
¶
Bases: _ArtifactBase
Full PyWry widget rendered inline as a sandboxed iframe.
Unlike :class:HtmlArtifact which carries only raw HTML, an
AppArtifact represents a complete PyWry app snapshot — inlined
CSS / JS / data — and optionally carries a live widget_id +
revision pair so the iframe can open a WebSocket bridge back to
the Python runtime for event traffic. When a new revision of the
same widget_id is emitted, older revisions close their bridge
server-side and the iframe stays frozen at its last known state
while remaining readable in chat history.
Attributes:
| Name | Type | Description |
|---|---|---|
artifact_type |
str
|
Fixed to |
html |
str
|
Self-contained HTML document (CSS / JS / data inlined). |
widget_id |
str | None
|
Optional backend identifier for live event wiring. When set,
the iframe opens a WebSocket carrying |
revision |
int
|
Monotonic render counter, incremented each time the widget is
re-rendered via the MCP layer. |
height |
str
|
CSS height for the iframe container. |
sandbox |
bool
|
If |
Attributes¶
ACP Session Primitives¶
pywry.chat.session.SessionMode
¶
Bases: BaseModel
An operational mode advertised by the agent.
Modes affect system prompts, tool availability, and permission requirements. Common examples: Ask, Architect, Code.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique identifier for the mode. |
name |
str
|
Human-readable title. |
description |
str | None
|
Optional explanation of mode behaviour. |
pywry.chat.session.SessionConfigOption
¶
Bases: BaseModel
A configurable, session-level setting exposed by the agent.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique identifier for the option. |
name |
str
|
Human-readable label. |
description |
str | None
|
Optional details about the option's purpose. |
category |
str | None
|
Semantic category — |
type |
str
|
Currently only |
currentValue |
str
|
The active setting value. |
options |
list[ConfigOptionChoice]
|
Available choices. |
pywry.chat.session.PlanEntry
¶
pywry.chat.session.PermissionRequest
¶
Bases: BaseModel
Agent request for user permission before tool execution.
Attributes:
| Name | Type | Description |
|---|---|---|
toolCallId |
str
|
The tool call requiring permission. |
title |
str
|
Human-readable description of what the tool will do. |
options |
list[PermissionOption]
|
Available user choices. |
request_id |
str
|
Stable identifier for correlating the response. |
Attributes¶
options
class-attribute
instance-attribute
¶
options: list[PermissionOption] = Field(default_factory=lambda: [PermissionOption(id='allow_once', label='Allow once'), PermissionOption(id='allow_always', label='Allow always'), PermissionOption(id='reject_once', label='Reject'), PermissionOption(id='reject_always', label='Always reject')])
request_id
class-attribute
instance-attribute
¶
pywry.chat.session.ClientCapabilities
¶
Bases: BaseModel
Capabilities the client advertises during initialize.
Attributes:
| Name | Type | Description |
|---|---|---|
fileSystem |
bool
|
Client supports |
terminal |
bool
|
Client supports |
pywry.chat.session.AgentCapabilities
¶
Bases: BaseModel
Capabilities the agent advertises during initialize.
Attributes:
| Name | Type | Description |
|---|---|---|
promptCapabilities |
PromptCapabilities | None
|
Supported prompt content types. |
loadSession |
bool
|
Agent supports |
configOptions |
bool
|
Agent supports |
modes |
bool
|
Agent supports |
Content Models¶
pywry.chat.models.ACPToolCall
¶
Bases: BaseModel
ACP tool invocation attached to an assistant message.
Attributes:
| Name | Type | Description |
|---|---|---|
toolCallId |
str
|
Unique identifier within the session. |
title |
str
|
Human-readable description shown in the UI. |
name |
str
|
Tool name. |
kind |
str
|
Category from the ACP taxonomy. |
status |
str
|
Lifecycle state. |
arguments |
dict[str, Any]
|
Tool arguments. |
content |
list[ContentBlock] | None
|
Result content blocks (populated on completion). |
locations |
list[ToolCallLocation] | None
|
Affected file paths with optional line numbers. |
pywry.chat.models.ACPCommand
¶
Bases: BaseModel
ACP slash command advertised by the agent.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Command name (e.g. |
description |
str
|
Human-readable description. |
input |
ACPCommandInput | None
|
Optional input hints. |
pywry.chat.models.ChatMessage
¶
Bases: BaseModel
A single chat message.
Attributes:
| Name | Type | Description |
|---|---|---|
role |
str
|
Semantic role — |
content |
str | list[ContentBlock]
|
Message body as plain text or ACP content blocks. |
message_id |
str
|
Stable identifier used across UI and backend events. |
timestamp |
float
|
Unix timestamp when the message was created. |
metadata |
dict[str, Any]
|
Arbitrary provider- or application-specific metadata. |
tool_calls |
list[ACPToolCall] | None
|
Tool invocations attached to assistant messages. |
tool_call_id |
str | None
|
Tool-call identifier when this message is a tool result. |
model |
str | None
|
Model name that produced the message. |
usage |
dict[str, Any] | None
|
Token or billing metadata. |
stopped |
bool
|
Whether generation stopped early (e.g. cancellation). |
Attributes¶
message_id
class-attribute
instance-attribute
¶
metadata
class-attribute
instance-attribute
¶
Functions¶
validate_content_length
classmethod
¶
Reject content exceeding MAX_CONTENT_LENGTH.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str | list[ContentBlock]
|
Candidate message content. |
required |
Returns:
| Type | Description |
|---|---|
str | list[ContentBlock]
|
The original content when it satisfies size limits. |
Raises:
| Type | Description |
|---|---|
ValueError
|
When plain-text content exceeds |
text_content
¶
Return the plain-text content regardless of content type.
Returns:
| Type | Description |
|---|---|
str
|
The plain-text message body, flattening structured text parts. |
pywry.chat.models.ChatConfig
¶
Bases: BaseModel
Configuration for the chat engine.
Attributes:
| Name | Type | Description |
|---|---|---|
system_prompt |
str | None
|
Optional system prompt prepended to model conversations. |
model |
str
|
Default model identifier. |
temperature |
float
|
Sampling temperature. |
max_tokens |
int
|
Maximum token budget per generation. |
streaming |
bool
|
Enable streaming responses. |
persist |
bool
|
Persist chat history between sessions. |
UI State Models¶
pywry.chat.manager.SettingsItem
¶
Bases: BaseModel
Settings menu item shown in the gear dropdown.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Stable identifier. |
label |
str
|
User-visible label. |
type |
str
|
Control type. |
value |
Any
|
Current value. |
options |
list[str] | None
|
Allowed values for |
min |
float | None
|
Minimum for |
max |
float | None
|
Maximum for |
step |
float | None
|
Increment for |
RBAC¶
pywry.chat.permissions.check_acp_permission
async
¶
Check RBAC permission for an ACP operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_session
|
UserSession | None
|
Current user session. |
required |
widget_id
|
str
|
Widget scope for the permission check. |
required |
operation
|
str
|
ACP operation name (e.g. |
required |
session_store
|
SessionStore
|
Store for permission lookups. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the operation is permitted. |