nicegui-ai 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nicegui_ai-0.2.0/PKG-INFO +207 -0
- nicegui_ai-0.2.0/README.md +184 -0
- nicegui_ai-0.2.0/pyproject.toml +86 -0
- nicegui_ai-0.2.0/pyproject.toml.orig +81 -0
- nicegui_ai-0.2.0/src/nicegui_ai/__init__.py +96 -0
- nicegui_ai-0.2.0/src/nicegui_ai/adapters/__init__.py +15 -0
- nicegui_ai-0.2.0/src/nicegui_ai/adapters/agui.py +77 -0
- nicegui_ai-0.2.0/src/nicegui_ai/adapters/base.py +103 -0
- nicegui_ai-0.2.0/src/nicegui_ai/adapters/gemini.py +366 -0
- nicegui_ai-0.2.0/src/nicegui_ai/adapters/opencode.py +214 -0
- nicegui_ai-0.2.0/src/nicegui_ai/adapters/openrouter.py +301 -0
- nicegui_ai-0.2.0/src/nicegui_ai/approval_modal.py +144 -0
- nicegui_ai-0.2.0/src/nicegui_ai/artifact.py +182 -0
- nicegui_ai-0.2.0/src/nicegui_ai/artifact_viewer.py +319 -0
- nicegui_ai-0.2.0/src/nicegui_ai/branch.py +87 -0
- nicegui_ai-0.2.0/src/nicegui_ai/code_block.py +94 -0
- nicegui_ai-0.2.0/src/nicegui_ai/composer.py +268 -0
- nicegui_ai-0.2.0/src/nicegui_ai/demo.py +638 -0
- nicegui_ai-0.2.0/src/nicegui_ai/drawer.py +107 -0
- nicegui_ai-0.2.0/src/nicegui_ai/gallery.py +705 -0
- nicegui_ai-0.2.0/src/nicegui_ai/header.py +128 -0
- nicegui_ai-0.2.0/src/nicegui_ai/icons.py +218 -0
- nicegui_ai-0.2.0/src/nicegui_ai/markdown.py +152 -0
- nicegui_ai-0.2.0/src/nicegui_ai/message.py +467 -0
- nicegui_ai-0.2.0/src/nicegui_ai/model_selector.py +449 -0
- nicegui_ai-0.2.0/src/nicegui_ai/py.typed +0 -0
- nicegui_ai-0.2.0/src/nicegui_ai/queued_messages.py +176 -0
- nicegui_ai-0.2.0/src/nicegui_ai/reasoning.py +103 -0
- nicegui_ai-0.2.0/src/nicegui_ai/schema.py +179 -0
- nicegui_ai-0.2.0/src/nicegui_ai/stream.py +250 -0
- nicegui_ai-0.2.0/src/nicegui_ai/task_tray.py +135 -0
- nicegui_ai-0.2.0/src/nicegui_ai/theme.py +129 -0
- nicegui_ai-0.2.0/src/nicegui_ai/thread.py +163 -0
- nicegui_ai-0.2.0/src/nicegui_ai/tool_call.py +257 -0
- nicegui_ai-0.2.0/src/nicegui_ai/voice_pill.py +116 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nicegui-ai
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Modern AI agent UI primitives for NiceGUI (1:1 port of assistant-ui and Vercel AI SDK)
|
|
5
|
+
Keywords: nicegui,ai,agent,assistant-ui,ui-components,llm,chat,reasoning,tool-calling
|
|
6
|
+
Author: Malcom Van Luther
|
|
7
|
+
Author-email: Malcom Van Luther <ivmno1special@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Framework :: AsyncIO
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Dist: nicegui>=3.18.0
|
|
18
|
+
Requires-Python: >=3.13
|
|
19
|
+
Project-URL: Homepage, https://github.com/IAmNo1Special/nicegui-ai
|
|
20
|
+
Project-URL: Repository, https://github.com/IAmNo1Special/nicegui-ai
|
|
21
|
+
Project-URL: Issues, https://github.com/IAmNo1Special/nicegui-ai/issues
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# nicegui-ai 🤖✨
|
|
25
|
+
|
|
26
|
+
**Modern, production-grade AI agent UI primitives for NiceGUI.**
|
|
27
|
+
A clean 1:1 Python port of contemporary AI interface patterns (inspired by `@assistant-ui/react` and Vercel AI SDK).
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Why `nicegui-ai`?
|
|
32
|
+
|
|
33
|
+
Python has great AI agent engines, but lacks modern, sleek interfaces. Streamlit is static and full-page refreshes, Gradio is rigid, and NiceGUI out of the box only provides basic Quasar chat bubbles (`ui.chat_message`).
|
|
34
|
+
|
|
35
|
+
`nicegui-ai` fills this gap by providing **pre-styled, high-polish, reactive components** specifically designed for autonomous agents, tool execution, multi-turn reasoning, and human-in-the-loop steering.
|
|
36
|
+
|
|
37
|
+
* 🔮 **Ambient Glass & Canvas**: Deep dark-mode canvas (`#0d1017`) with spacious centering and floating glassmorphism docks (`backdrop-blur-xl`).
|
|
38
|
+
* 🧠 **Reasoning Blocks**: Amber-gilded collapsible reasoning cards displaying live step counts and monospace thoughts.
|
|
39
|
+
* ⚡ **Tool Call Cards**: Runic command cards with live status badges (`Executing...`, `Resolved`, `Failed`), collapsible arguments, and interactive Approval Gate buttons (**[Approve]** and **[Veto]**).
|
|
40
|
+
* 🔄 **In-Stream Branching**: `< 1 / 3 >` branch pickers to inspect alternative completions or user edits.
|
|
41
|
+
* ✍️ **Steerable Composer**: Auto-expanding dock with 3-state Action Button (Send / Stop / Queue), in-flight message queue tray, background task indicators, and multiline support (`Shift+Enter` for newline, `Enter` to submit).
|
|
42
|
+
* 📬 **Queued Messages Tray**: In-flight steering buffer with FIFO auto-draining, Send Now, Edit, and Delete actions.
|
|
43
|
+
* ⚙️ **Background Task Tray**: Monospace status indicators with spinners for asynchronous agent jobs.
|
|
44
|
+
* 📊 **Organic Token Ring**: Smooth animated circular SVG progress gauge for context window budget tracking.
|
|
45
|
+
* 📑 **Slide-Over Drawers**: Ephemeral slide-out sheets for conversation histories, diff reviews, and live artifacts.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv add nicegui-ai
|
|
53
|
+
# or with pip fallback:
|
|
54
|
+
pip install nicegui-ai
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Quickstart
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import asyncio
|
|
63
|
+
from nicegui import ui
|
|
64
|
+
from nicegui_ai import (
|
|
65
|
+
setup_ai_theme,
|
|
66
|
+
FloatingHeader,
|
|
67
|
+
AiThread,
|
|
68
|
+
AiComposer,
|
|
69
|
+
ToolCall,
|
|
70
|
+
ToolStatus,
|
|
71
|
+
SuggestionPrompt,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@ui.page("/")
|
|
76
|
+
def index():
|
|
77
|
+
# 1. Inject ambient dark theme & custom scrollbars
|
|
78
|
+
setup_ai_theme()
|
|
79
|
+
|
|
80
|
+
# 2. Ambient floating glass header with circular token gauge
|
|
81
|
+
header = FloatingHeader(
|
|
82
|
+
agent_name="code-agent",
|
|
83
|
+
model="claude-3-7-sonnet",
|
|
84
|
+
tokens_used=14200,
|
|
85
|
+
token_limit=128000,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# 3. Centered AI conversation thread
|
|
89
|
+
with ui.column().classes(
|
|
90
|
+
"w-full max-w-3xl mx-auto h-screen pt-20 pb-4 px-4 overflow-hidden"
|
|
91
|
+
):
|
|
92
|
+
thread = AiThread(
|
|
93
|
+
welcome_title="How can I help you today?",
|
|
94
|
+
suggestions=[
|
|
95
|
+
SuggestionPrompt(label="Run Tests", prompt="uv run pytest tests/"),
|
|
96
|
+
SuggestionPrompt(label="Inspect Git Diff", prompt="git diff --staged"),
|
|
97
|
+
],
|
|
98
|
+
on_suggestion_click=lambda p: composer.input.set_value(p),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
async def handle_submit(prompt: str):
|
|
102
|
+
composer.set_running(True)
|
|
103
|
+
thread.add_user_message(prompt)
|
|
104
|
+
|
|
105
|
+
# Agent response with reasoning and tool call
|
|
106
|
+
agent = thread.add_agent_message(agent_name="Agent")
|
|
107
|
+
agent.set_generating(True)
|
|
108
|
+
|
|
109
|
+
# Stream reasoning thoughts
|
|
110
|
+
reasoning = agent.add_reasoning("")
|
|
111
|
+
reasoning.append_thought("Analyzing requirements...\n", step_count=1)
|
|
112
|
+
await asyncio.sleep(0.4)
|
|
113
|
+
reasoning.append_thought("Running validation tool...\n", step_count=2)
|
|
114
|
+
|
|
115
|
+
# Execute tool call
|
|
116
|
+
tool = agent.add_tool_call(
|
|
117
|
+
ToolCall(id="t1", name="run_command", args={"command": "pytest"})
|
|
118
|
+
)
|
|
119
|
+
await asyncio.sleep(0.5)
|
|
120
|
+
tool.resolve("9 passed in 0.42s")
|
|
121
|
+
|
|
122
|
+
# Stream final markdown text
|
|
123
|
+
agent.append_text("All checks passed successfully!")
|
|
124
|
+
agent.set_generating(False)
|
|
125
|
+
composer.set_running(False)
|
|
126
|
+
header.update_tokens(14850)
|
|
127
|
+
|
|
128
|
+
# 4. Pill prompt composer with unified action button and steering
|
|
129
|
+
composer = AiComposer(
|
|
130
|
+
placeholder="Message AI agent... (type / for commands, @ for files)",
|
|
131
|
+
on_send=lambda text: asyncio.create_task(handle_submit(text)),
|
|
132
|
+
on_cancel=lambda: ui.notify("Generation stopped", type="warning"),
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
ui.run(port=8080)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Component Catalog
|
|
142
|
+
|
|
143
|
+
| Component | Description |
|
|
144
|
+
| :--- | :--- |
|
|
145
|
+
| **`AiThread`** | Spacious conversation container with auto-scrolling and empty suggestion pills. |
|
|
146
|
+
| **`UserMessage`** | Right-aligned message bubble with tailored `rounded-tr-sm` corner. |
|
|
147
|
+
| **`AgentMessage`** | Left-aligned message bubble with avatar, status badge, reasoning, and tool call slots. |
|
|
148
|
+
| **`ReasoningCard`** | Amber-gilded collapsible card displaying model chain-of-thought and step counts. |
|
|
149
|
+
| **`ToolCallCard`** | Inspectable tool execution card with arguments, results, and Human-in-the-Loop Approval Gates. |
|
|
150
|
+
| **`AiComposer`** | Steerable input dock with 3-state Action Button, integrated model selector, and audio pill. |
|
|
151
|
+
| **`QueuedMessagesTray`** | FIFO message queue tray anchored above the composer for in-flight steering with Send Now, Edit, and Delete actions. |
|
|
152
|
+
| **`TaskTray`** | Live status tray displaying asynchronous background tasks with spinners and monospace labels. |
|
|
153
|
+
| **`BranchPicker`** | Inline `< 1 / 3 >` branch switcher for multi-turn alternative explorations. |
|
|
154
|
+
| **`FloatingHeader`** | Ambient glassmorphism pill with model identity and circular token meter. |
|
|
155
|
+
| **`TokenRing`** | Standalone animated SVG circular progress ring for context window tracking. |
|
|
156
|
+
| **`SlideOverDrawer`** | Smooth off-canvas sheet with soft backdrop scrim for session lists and artifacts. |
|
|
157
|
+
| **`CodeBlock`** | Monospace code block with language indicator, filename, line numbers, and copy button. |
|
|
158
|
+
| **`ArtifactCard`** | Interactive card representing agent artifacts (code, reports, diffs) with copy and download. |
|
|
159
|
+
| **`ArtifactViewerDrawer`** | Full-featured off-canvas drawer with tabbed Code (syntax highlighted, line numbers), Live Render (HTML/SVG, Mermaid, Markdown), and Unified Diff view (+/- line highlights). |
|
|
160
|
+
| **`StreamBridge`** | Reactive streaming orchestrator that consumes AG-UI events and drives UI updates (text, reasoning, tools, tasks, tokens). |
|
|
161
|
+
| **`BaseStreamAdapter`** | Object-oriented adapter hierarchy (`OpenRouterStreamAdapter`, `GeminiStreamAdapter`, `OpenCodeStreamAdapter`, `AgUiStreamAdapter`) translating provider events to normalized AG-UI protocol. |
|
|
162
|
+
| **`MessageBranch`** | Dataclass encapsulating branch state (text, reasoning, tool calls, tokens) for reactive turn switching and forking. |
|
|
163
|
+
| **`ApprovalModal`** | Ambient glassmorphism modal dialog for human-in-the-loop security gates. |
|
|
164
|
+
| **`ModelSelector`** | Floating pill dropdown or inline composer selector for active model and reasoning effort. |
|
|
165
|
+
| **`VoicePill`** | Audio streaming indicator and push-to-talk pill with animated waveforms. |
|
|
166
|
+
| **`AiMarkdown`** | Markdown renderer that auto-converts fenced code into interactive `CodeBlock` components with incremental streaming. |
|
|
167
|
+
| **`LucideIcon`** | Crisp outline SVG icon primitive matching contemporary AI developer tooling. |
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Live Showcase Demo & Component Gallery
|
|
172
|
+
|
|
173
|
+
Run the interactive live demo showcasing end-to-end agent streaming with reasoning, tools, and queued steering:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
uv run python -m nicegui_ai.demo
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Or open the **Component Gallery** to inspect every single primitive across all its visual states:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
uv run python -m nicegui_ai.gallery
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Then open your browser at **http://localhost:8080**.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Development & Testing
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Run tests
|
|
193
|
+
uv run pytest
|
|
194
|
+
|
|
195
|
+
# Check formatting and linting
|
|
196
|
+
uv run ruff check .
|
|
197
|
+
uv run ruff format --check .
|
|
198
|
+
|
|
199
|
+
# Type checking (strict mode)
|
|
200
|
+
uv run mypy src/
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
MIT License. Designed for the Python AI agent community.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# nicegui-ai 🤖✨
|
|
2
|
+
|
|
3
|
+
**Modern, production-grade AI agent UI primitives for NiceGUI.**
|
|
4
|
+
A clean 1:1 Python port of contemporary AI interface patterns (inspired by `@assistant-ui/react` and Vercel AI SDK).
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Why `nicegui-ai`?
|
|
9
|
+
|
|
10
|
+
Python has great AI agent engines, but lacks modern, sleek interfaces. Streamlit is static and full-page refreshes, Gradio is rigid, and NiceGUI out of the box only provides basic Quasar chat bubbles (`ui.chat_message`).
|
|
11
|
+
|
|
12
|
+
`nicegui-ai` fills this gap by providing **pre-styled, high-polish, reactive components** specifically designed for autonomous agents, tool execution, multi-turn reasoning, and human-in-the-loop steering.
|
|
13
|
+
|
|
14
|
+
* 🔮 **Ambient Glass & Canvas**: Deep dark-mode canvas (`#0d1017`) with spacious centering and floating glassmorphism docks (`backdrop-blur-xl`).
|
|
15
|
+
* 🧠 **Reasoning Blocks**: Amber-gilded collapsible reasoning cards displaying live step counts and monospace thoughts.
|
|
16
|
+
* ⚡ **Tool Call Cards**: Runic command cards with live status badges (`Executing...`, `Resolved`, `Failed`), collapsible arguments, and interactive Approval Gate buttons (**[Approve]** and **[Veto]**).
|
|
17
|
+
* 🔄 **In-Stream Branching**: `< 1 / 3 >` branch pickers to inspect alternative completions or user edits.
|
|
18
|
+
* ✍️ **Steerable Composer**: Auto-expanding dock with 3-state Action Button (Send / Stop / Queue), in-flight message queue tray, background task indicators, and multiline support (`Shift+Enter` for newline, `Enter` to submit).
|
|
19
|
+
* 📬 **Queued Messages Tray**: In-flight steering buffer with FIFO auto-draining, Send Now, Edit, and Delete actions.
|
|
20
|
+
* ⚙️ **Background Task Tray**: Monospace status indicators with spinners for asynchronous agent jobs.
|
|
21
|
+
* 📊 **Organic Token Ring**: Smooth animated circular SVG progress gauge for context window budget tracking.
|
|
22
|
+
* 📑 **Slide-Over Drawers**: Ephemeral slide-out sheets for conversation histories, diff reviews, and live artifacts.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv add nicegui-ai
|
|
30
|
+
# or with pip fallback:
|
|
31
|
+
pip install nicegui-ai
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quickstart
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import asyncio
|
|
40
|
+
from nicegui import ui
|
|
41
|
+
from nicegui_ai import (
|
|
42
|
+
setup_ai_theme,
|
|
43
|
+
FloatingHeader,
|
|
44
|
+
AiThread,
|
|
45
|
+
AiComposer,
|
|
46
|
+
ToolCall,
|
|
47
|
+
ToolStatus,
|
|
48
|
+
SuggestionPrompt,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@ui.page("/")
|
|
53
|
+
def index():
|
|
54
|
+
# 1. Inject ambient dark theme & custom scrollbars
|
|
55
|
+
setup_ai_theme()
|
|
56
|
+
|
|
57
|
+
# 2. Ambient floating glass header with circular token gauge
|
|
58
|
+
header = FloatingHeader(
|
|
59
|
+
agent_name="code-agent",
|
|
60
|
+
model="claude-3-7-sonnet",
|
|
61
|
+
tokens_used=14200,
|
|
62
|
+
token_limit=128000,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# 3. Centered AI conversation thread
|
|
66
|
+
with ui.column().classes(
|
|
67
|
+
"w-full max-w-3xl mx-auto h-screen pt-20 pb-4 px-4 overflow-hidden"
|
|
68
|
+
):
|
|
69
|
+
thread = AiThread(
|
|
70
|
+
welcome_title="How can I help you today?",
|
|
71
|
+
suggestions=[
|
|
72
|
+
SuggestionPrompt(label="Run Tests", prompt="uv run pytest tests/"),
|
|
73
|
+
SuggestionPrompt(label="Inspect Git Diff", prompt="git diff --staged"),
|
|
74
|
+
],
|
|
75
|
+
on_suggestion_click=lambda p: composer.input.set_value(p),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
async def handle_submit(prompt: str):
|
|
79
|
+
composer.set_running(True)
|
|
80
|
+
thread.add_user_message(prompt)
|
|
81
|
+
|
|
82
|
+
# Agent response with reasoning and tool call
|
|
83
|
+
agent = thread.add_agent_message(agent_name="Agent")
|
|
84
|
+
agent.set_generating(True)
|
|
85
|
+
|
|
86
|
+
# Stream reasoning thoughts
|
|
87
|
+
reasoning = agent.add_reasoning("")
|
|
88
|
+
reasoning.append_thought("Analyzing requirements...\n", step_count=1)
|
|
89
|
+
await asyncio.sleep(0.4)
|
|
90
|
+
reasoning.append_thought("Running validation tool...\n", step_count=2)
|
|
91
|
+
|
|
92
|
+
# Execute tool call
|
|
93
|
+
tool = agent.add_tool_call(
|
|
94
|
+
ToolCall(id="t1", name="run_command", args={"command": "pytest"})
|
|
95
|
+
)
|
|
96
|
+
await asyncio.sleep(0.5)
|
|
97
|
+
tool.resolve("9 passed in 0.42s")
|
|
98
|
+
|
|
99
|
+
# Stream final markdown text
|
|
100
|
+
agent.append_text("All checks passed successfully!")
|
|
101
|
+
agent.set_generating(False)
|
|
102
|
+
composer.set_running(False)
|
|
103
|
+
header.update_tokens(14850)
|
|
104
|
+
|
|
105
|
+
# 4. Pill prompt composer with unified action button and steering
|
|
106
|
+
composer = AiComposer(
|
|
107
|
+
placeholder="Message AI agent... (type / for commands, @ for files)",
|
|
108
|
+
on_send=lambda text: asyncio.create_task(handle_submit(text)),
|
|
109
|
+
on_cancel=lambda: ui.notify("Generation stopped", type="warning"),
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
ui.run(port=8080)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Component Catalog
|
|
119
|
+
|
|
120
|
+
| Component | Description |
|
|
121
|
+
| :--- | :--- |
|
|
122
|
+
| **`AiThread`** | Spacious conversation container with auto-scrolling and empty suggestion pills. |
|
|
123
|
+
| **`UserMessage`** | Right-aligned message bubble with tailored `rounded-tr-sm` corner. |
|
|
124
|
+
| **`AgentMessage`** | Left-aligned message bubble with avatar, status badge, reasoning, and tool call slots. |
|
|
125
|
+
| **`ReasoningCard`** | Amber-gilded collapsible card displaying model chain-of-thought and step counts. |
|
|
126
|
+
| **`ToolCallCard`** | Inspectable tool execution card with arguments, results, and Human-in-the-Loop Approval Gates. |
|
|
127
|
+
| **`AiComposer`** | Steerable input dock with 3-state Action Button, integrated model selector, and audio pill. |
|
|
128
|
+
| **`QueuedMessagesTray`** | FIFO message queue tray anchored above the composer for in-flight steering with Send Now, Edit, and Delete actions. |
|
|
129
|
+
| **`TaskTray`** | Live status tray displaying asynchronous background tasks with spinners and monospace labels. |
|
|
130
|
+
| **`BranchPicker`** | Inline `< 1 / 3 >` branch switcher for multi-turn alternative explorations. |
|
|
131
|
+
| **`FloatingHeader`** | Ambient glassmorphism pill with model identity and circular token meter. |
|
|
132
|
+
| **`TokenRing`** | Standalone animated SVG circular progress ring for context window tracking. |
|
|
133
|
+
| **`SlideOverDrawer`** | Smooth off-canvas sheet with soft backdrop scrim for session lists and artifacts. |
|
|
134
|
+
| **`CodeBlock`** | Monospace code block with language indicator, filename, line numbers, and copy button. |
|
|
135
|
+
| **`ArtifactCard`** | Interactive card representing agent artifacts (code, reports, diffs) with copy and download. |
|
|
136
|
+
| **`ArtifactViewerDrawer`** | Full-featured off-canvas drawer with tabbed Code (syntax highlighted, line numbers), Live Render (HTML/SVG, Mermaid, Markdown), and Unified Diff view (+/- line highlights). |
|
|
137
|
+
| **`StreamBridge`** | Reactive streaming orchestrator that consumes AG-UI events and drives UI updates (text, reasoning, tools, tasks, tokens). |
|
|
138
|
+
| **`BaseStreamAdapter`** | Object-oriented adapter hierarchy (`OpenRouterStreamAdapter`, `GeminiStreamAdapter`, `OpenCodeStreamAdapter`, `AgUiStreamAdapter`) translating provider events to normalized AG-UI protocol. |
|
|
139
|
+
| **`MessageBranch`** | Dataclass encapsulating branch state (text, reasoning, tool calls, tokens) for reactive turn switching and forking. |
|
|
140
|
+
| **`ApprovalModal`** | Ambient glassmorphism modal dialog for human-in-the-loop security gates. |
|
|
141
|
+
| **`ModelSelector`** | Floating pill dropdown or inline composer selector for active model and reasoning effort. |
|
|
142
|
+
| **`VoicePill`** | Audio streaming indicator and push-to-talk pill with animated waveforms. |
|
|
143
|
+
| **`AiMarkdown`** | Markdown renderer that auto-converts fenced code into interactive `CodeBlock` components with incremental streaming. |
|
|
144
|
+
| **`LucideIcon`** | Crisp outline SVG icon primitive matching contemporary AI developer tooling. |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Live Showcase Demo & Component Gallery
|
|
149
|
+
|
|
150
|
+
Run the interactive live demo showcasing end-to-end agent streaming with reasoning, tools, and queued steering:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
uv run python -m nicegui_ai.demo
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or open the **Component Gallery** to inspect every single primitive across all its visual states:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
uv run python -m nicegui_ai.gallery
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Then open your browser at **http://localhost:8080**.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Development & Testing
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Run tests
|
|
170
|
+
uv run pytest
|
|
171
|
+
|
|
172
|
+
# Check formatting and linting
|
|
173
|
+
uv run ruff check .
|
|
174
|
+
uv run ruff format --check .
|
|
175
|
+
|
|
176
|
+
# Type checking (strict mode)
|
|
177
|
+
uv run mypy src/
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
MIT License. Designed for the Python AI agent community.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "nicegui-ai"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "Modern AI agent UI primitives for NiceGUI (1:1 port of assistant-ui and Vercel AI SDK)"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
requires-python = ">=3.13"
|
|
8
|
+
keywords = [
|
|
9
|
+
"nicegui",
|
|
10
|
+
"ai",
|
|
11
|
+
"agent",
|
|
12
|
+
"assistant-ui",
|
|
13
|
+
"ui-components",
|
|
14
|
+
"llm",
|
|
15
|
+
"chat",
|
|
16
|
+
"reasoning",
|
|
17
|
+
"tool-calling",
|
|
18
|
+
]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 4 - Beta",
|
|
21
|
+
"Framework :: AsyncIO",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Software Development :: User Interfaces",
|
|
27
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
28
|
+
]
|
|
29
|
+
dependencies = ["nicegui>=3.18.0"]
|
|
30
|
+
|
|
31
|
+
[[project.authors]]
|
|
32
|
+
name = "Malcom Van Luther"
|
|
33
|
+
email = "ivmno1special@gmail.com"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
nicegui-ai = "nicegui_ai.gallery:main"
|
|
37
|
+
nicegui-ai-demo = "nicegui_ai.demo:main"
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/IAmNo1Special/nicegui-ai"
|
|
41
|
+
Repository = "https://github.com/IAmNo1Special/nicegui-ai"
|
|
42
|
+
Issues = "https://github.com/IAmNo1Special/nicegui-ai/issues"
|
|
43
|
+
|
|
44
|
+
[build-system]
|
|
45
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
46
|
+
build-backend = "uv_build"
|
|
47
|
+
|
|
48
|
+
[dependency-groups]
|
|
49
|
+
dev = [
|
|
50
|
+
"mypy>=2.4.0",
|
|
51
|
+
"pytest>=9.1.1",
|
|
52
|
+
"pytest-asyncio>=1.4.0",
|
|
53
|
+
"ruff>=0.17.2",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[tool.ruff]
|
|
57
|
+
line-length = 88
|
|
58
|
+
target-version = "py313"
|
|
59
|
+
|
|
60
|
+
[tool.ruff.lint]
|
|
61
|
+
select = [
|
|
62
|
+
"E",
|
|
63
|
+
"W",
|
|
64
|
+
"F",
|
|
65
|
+
"I",
|
|
66
|
+
"UP",
|
|
67
|
+
"B",
|
|
68
|
+
"SIM",
|
|
69
|
+
]
|
|
70
|
+
ignore = [
|
|
71
|
+
"E501",
|
|
72
|
+
"SIM117",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.mypy]
|
|
76
|
+
python_version = "3.13"
|
|
77
|
+
strict = true
|
|
78
|
+
warn_unreachable = true
|
|
79
|
+
exclude = [
|
|
80
|
+
"tests/",
|
|
81
|
+
"demo/",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[tool.pytest.ini_options]
|
|
85
|
+
asyncio_mode = "auto"
|
|
86
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "nicegui-ai"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "Modern AI agent UI primitives for NiceGUI (1:1 port of assistant-ui and Vercel AI SDK)"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Malcom Van Luther", email = "ivmno1special@gmail.com" }
|
|
9
|
+
]
|
|
10
|
+
requires-python = ">=3.13"
|
|
11
|
+
keywords = [
|
|
12
|
+
"nicegui",
|
|
13
|
+
"ai",
|
|
14
|
+
"agent",
|
|
15
|
+
"assistant-ui",
|
|
16
|
+
"ui-components",
|
|
17
|
+
"llm",
|
|
18
|
+
"chat",
|
|
19
|
+
"reasoning",
|
|
20
|
+
"tool-calling",
|
|
21
|
+
]
|
|
22
|
+
classifiers = [
|
|
23
|
+
"Development Status :: 4 - Beta",
|
|
24
|
+
"Framework :: AsyncIO",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Operating System :: OS Independent",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Topic :: Software Development :: User Interfaces",
|
|
30
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
31
|
+
]
|
|
32
|
+
dependencies = [
|
|
33
|
+
"nicegui>=3.18.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
nicegui-ai = "nicegui_ai.gallery:main"
|
|
38
|
+
nicegui-ai-demo = "nicegui_ai.demo:main"
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/IAmNo1Special/nicegui-ai"
|
|
42
|
+
Repository = "https://github.com/IAmNo1Special/nicegui-ai"
|
|
43
|
+
Issues = "https://github.com/IAmNo1Special/nicegui-ai/issues"
|
|
44
|
+
|
|
45
|
+
[build-system]
|
|
46
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
47
|
+
build-backend = "uv_build"
|
|
48
|
+
|
|
49
|
+
[dependency-groups]
|
|
50
|
+
dev = [
|
|
51
|
+
"mypy>=2.4.0",
|
|
52
|
+
"pytest>=9.1.1",
|
|
53
|
+
"pytest-asyncio>=1.4.0",
|
|
54
|
+
"ruff>=0.17.2",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[tool.ruff]
|
|
58
|
+
line-length = 88
|
|
59
|
+
target-version = "py313"
|
|
60
|
+
|
|
61
|
+
[tool.ruff.lint]
|
|
62
|
+
select = [
|
|
63
|
+
"E",
|
|
64
|
+
"W",
|
|
65
|
+
"F",
|
|
66
|
+
"I",
|
|
67
|
+
"UP",
|
|
68
|
+
"B",
|
|
69
|
+
"SIM",
|
|
70
|
+
]
|
|
71
|
+
ignore = ["E501", "SIM117"]
|
|
72
|
+
|
|
73
|
+
[tool.mypy]
|
|
74
|
+
python_version = "3.13"
|
|
75
|
+
strict = true
|
|
76
|
+
warn_unreachable = true
|
|
77
|
+
exclude = ["tests/", "demo/"]
|
|
78
|
+
|
|
79
|
+
[tool.pytest.ini_options]
|
|
80
|
+
asyncio_mode = "auto"
|
|
81
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""nicegui-ai: Modern AI agent UI primitives for NiceGUI."""
|
|
2
|
+
|
|
3
|
+
from nicegui_ai.adapters import (
|
|
4
|
+
AgUiStreamAdapter,
|
|
5
|
+
BaseStreamAdapter,
|
|
6
|
+
GeminiStreamAdapter,
|
|
7
|
+
OpenCodeStreamAdapter,
|
|
8
|
+
OpenRouterStreamAdapter,
|
|
9
|
+
)
|
|
10
|
+
from nicegui_ai.approval_modal import ApprovalModal
|
|
11
|
+
from nicegui_ai.artifact import ArtifactCard
|
|
12
|
+
from nicegui_ai.artifact_viewer import ArtifactViewerDrawer
|
|
13
|
+
from nicegui_ai.branch import BranchPicker
|
|
14
|
+
from nicegui_ai.code_block import CodeBlock
|
|
15
|
+
from nicegui_ai.composer import AiComposer
|
|
16
|
+
from nicegui_ai.drawer import SlideOverDrawer
|
|
17
|
+
from nicegui_ai.header import FloatingHeader, TokenRing
|
|
18
|
+
from nicegui_ai.icons import LucideIcon, get_lucide_svg
|
|
19
|
+
from nicegui_ai.markdown import AiMarkdown, parse_markdown_blocks
|
|
20
|
+
from nicegui_ai.message import AgentMessage, UserMessage
|
|
21
|
+
from nicegui_ai.model_selector import (
|
|
22
|
+
ModelOption,
|
|
23
|
+
ModelSelector,
|
|
24
|
+
ReasoningEffortSelector,
|
|
25
|
+
)
|
|
26
|
+
from nicegui_ai.queued_messages import QueuedMessagesTray
|
|
27
|
+
from nicegui_ai.reasoning import ReasoningCard
|
|
28
|
+
from nicegui_ai.schema import (
|
|
29
|
+
AgUiEvent,
|
|
30
|
+
AgUiEventType,
|
|
31
|
+
ChatMessage,
|
|
32
|
+
MessageBranch,
|
|
33
|
+
MessageRole,
|
|
34
|
+
QueuedMessage,
|
|
35
|
+
ReasoningStep,
|
|
36
|
+
RunningTask,
|
|
37
|
+
SuggestionPrompt,
|
|
38
|
+
ToolCall,
|
|
39
|
+
ToolStatus,
|
|
40
|
+
)
|
|
41
|
+
from nicegui_ai.stream import StreamBridge, StreamResult
|
|
42
|
+
from nicegui_ai.task_tray import TaskHandle, TaskTray
|
|
43
|
+
from nicegui_ai.theme import THEME_CSS, setup_ai_theme
|
|
44
|
+
from nicegui_ai.thread import AiThread
|
|
45
|
+
from nicegui_ai.tool_call import ToolCallCard
|
|
46
|
+
from nicegui_ai.voice_pill import VoicePill
|
|
47
|
+
|
|
48
|
+
__version__ = "0.2.0"
|
|
49
|
+
|
|
50
|
+
__all__ = [
|
|
51
|
+
"AgUiEvent",
|
|
52
|
+
"AgUiEventType",
|
|
53
|
+
"AgUiStreamAdapter",
|
|
54
|
+
"AgentMessage",
|
|
55
|
+
"AiComposer",
|
|
56
|
+
"AiMarkdown",
|
|
57
|
+
"AiThread",
|
|
58
|
+
"ApprovalModal",
|
|
59
|
+
"ArtifactCard",
|
|
60
|
+
"ArtifactViewerDrawer",
|
|
61
|
+
"BaseStreamAdapter",
|
|
62
|
+
"BranchPicker",
|
|
63
|
+
"ChatMessage",
|
|
64
|
+
"CodeBlock",
|
|
65
|
+
"FloatingHeader",
|
|
66
|
+
"GeminiStreamAdapter",
|
|
67
|
+
"LucideIcon",
|
|
68
|
+
"MessageBranch",
|
|
69
|
+
"MessageRole",
|
|
70
|
+
"ModelOption",
|
|
71
|
+
"ModelSelector",
|
|
72
|
+
"OpenCodeStreamAdapter",
|
|
73
|
+
"OpenRouterStreamAdapter",
|
|
74
|
+
"QueuedMessage",
|
|
75
|
+
"QueuedMessagesTray",
|
|
76
|
+
"ReasoningCard",
|
|
77
|
+
"ReasoningEffortSelector",
|
|
78
|
+
"ReasoningStep",
|
|
79
|
+
"RunningTask",
|
|
80
|
+
"SlideOverDrawer",
|
|
81
|
+
"StreamBridge",
|
|
82
|
+
"StreamResult",
|
|
83
|
+
"SuggestionPrompt",
|
|
84
|
+
"THEME_CSS",
|
|
85
|
+
"TaskHandle",
|
|
86
|
+
"TaskTray",
|
|
87
|
+
"TokenRing",
|
|
88
|
+
"ToolCall",
|
|
89
|
+
"ToolCallCard",
|
|
90
|
+
"ToolStatus",
|
|
91
|
+
"UserMessage",
|
|
92
|
+
"VoicePill",
|
|
93
|
+
"get_lucide_svg",
|
|
94
|
+
"parse_markdown_blocks",
|
|
95
|
+
"setup_ai_theme",
|
|
96
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""AG-UI stream adapters for OpenRouter, Gemini, OpenCode, and native AG-UI sources."""
|
|
2
|
+
|
|
3
|
+
from nicegui_ai.adapters.agui import AgUiStreamAdapter
|
|
4
|
+
from nicegui_ai.adapters.base import BaseStreamAdapter
|
|
5
|
+
from nicegui_ai.adapters.gemini import GeminiStreamAdapter
|
|
6
|
+
from nicegui_ai.adapters.opencode import OpenCodeStreamAdapter
|
|
7
|
+
from nicegui_ai.adapters.openrouter import OpenRouterStreamAdapter
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"AgUiStreamAdapter",
|
|
11
|
+
"BaseStreamAdapter",
|
|
12
|
+
"GeminiStreamAdapter",
|
|
13
|
+
"OpenCodeStreamAdapter",
|
|
14
|
+
"OpenRouterStreamAdapter",
|
|
15
|
+
]
|