Skip to main content

nicegui-ai 🤖✨

Modern, production-grade AI agent UI primitives for NiceGUI.
A clean 1:1 Python port of contemporary AI interface patterns (inspired by @assistant-ui/react and Vercel AI SDK).


Why nicegui-ai?

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).

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.

  • 🔮 Ambient Glass & Canvas: Deep dark-mode canvas (#0d1017) with spacious centering and floating glassmorphism docks (backdrop-blur-xl).
  • 🧠 Reasoning Blocks: Amber-gilded collapsible reasoning cards displaying live step counts and monospace thoughts.
  • ⚡ Tool Call Cards: Runic command cards with live status badges (Executing..., Resolved, Failed), collapsible arguments, and interactive Approval Gate buttons ([Approve] and [Veto]).
  • 🔄 In-Stream Branching: < 1 / 3 > branch pickers to inspect alternative completions or user edits.
  • ✍️ 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).
  • 📬 Queued Messages Tray: In-flight steering buffer with FIFO auto-draining, Send Now, Edit, and Delete actions.
  • ⚙️ Background Task Tray: Monospace status indicators with spinners for asynchronous agent jobs.
  • 📊 Organic Token Ring: Smooth animated circular SVG progress gauge for context window budget tracking.
  • 📑 Slide-Over Drawers: Ephemeral slide-out sheets for conversation histories, diff reviews, and live artifacts.

Installation

uv add nicegui-ai
# or with pip fallback:
pip install nicegui-ai

Quickstart

import asyncio
from nicegui import ui
from nicegui_ai import (
    setup_ai_theme,
    FloatingHeader,
    AiThread,
    AiComposer,
    ToolCall,
    ToolStatus,
    SuggestionPrompt,
)


@ui.page("/")
def index():
    # 1. Inject ambient dark theme & custom scrollbars
    setup_ai_theme()

    # 2. Ambient floating glass header with circular token gauge
    header = FloatingHeader(
        agent_name="code-agent",
        model="claude-3-7-sonnet",
        tokens_used=14200,
        token_limit=128000,
    )

    # 3. Centered AI conversation thread
    with ui.column().classes(
        "w-full max-w-3xl mx-auto h-screen pt-20 pb-4 px-4 overflow-hidden"
    ):
        thread = AiThread(
            welcome_title="How can I help you today?",
            suggestions=[
                SuggestionPrompt(label="Run Tests", prompt="uv run pytest tests/"),
                SuggestionPrompt(label="Inspect Git Diff", prompt="git diff --staged"),
            ],
            on_suggestion_click=lambda p: composer.input.set_value(p),
        )

        async def handle_submit(prompt: str):
            composer.set_running(True)
            thread.add_user_message(prompt)

            # Agent response with reasoning and tool call
            agent = thread.add_agent_message(agent_name="Agent")
            agent.set_generating(True)

            # Stream reasoning thoughts
            reasoning = agent.add_reasoning("")
            reasoning.append_thought("Analyzing requirements...\n", step_count=1)
            await asyncio.sleep(0.4)
            reasoning.append_thought("Running validation tool...\n", step_count=2)

            # Execute tool call
            tool = agent.add_tool_call(
                ToolCall(id="t1", name="run_command", args={"command": "pytest"})
            )
            await asyncio.sleep(0.5)
            tool.resolve("9 passed in 0.42s")

            # Stream final markdown text
            agent.append_text("All checks passed successfully!")
            agent.set_generating(False)
            composer.set_running(False)
            header.update_tokens(14850)

        # 4. Pill prompt composer with unified action button and steering
        composer = AiComposer(
            placeholder="Message AI agent... (type / for commands, @ for files)",
            on_send=lambda text: asyncio.create_task(handle_submit(text)),
            on_cancel=lambda: ui.notify("Generation stopped", type="warning"),
        )


ui.run(port=8080)

Component Catalog

Component Description
AiThread Spacious conversation container with auto-scrolling and empty suggestion pills.
UserMessage Right-aligned message bubble with tailored rounded-tr-sm corner.
AgentMessage Left-aligned message bubble with avatar, status badge, reasoning, and tool call slots.
ReasoningCard Amber-gilded collapsible card displaying model chain-of-thought and step counts.
ToolCallCard Inspectable tool execution card with arguments, results, and Human-in-the-Loop Approval Gates.
AiComposer Steerable input dock with 3-state Action Button, integrated model selector, and audio pill.
QueuedMessagesTray FIFO message queue tray anchored above the composer for in-flight steering with Send Now, Edit, and Delete actions.
TaskTray Live status tray displaying asynchronous background tasks with spinners and monospace labels.
BranchPicker Inline < 1 / 3 > branch switcher for multi-turn alternative explorations.
FloatingHeader Ambient glassmorphism pill with model identity and circular token meter.
TokenRing Standalone animated SVG circular progress ring for context window tracking.
SlideOverDrawer Smooth off-canvas sheet with soft backdrop scrim for session lists and artifacts.
CodeBlock Monospace code block with language indicator, filename, line numbers, and copy button.
ArtifactCard Interactive card representing agent artifacts (code, reports, diffs) with copy and download.
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).
StreamBridge Reactive streaming orchestrator that consumes AG-UI events and drives UI updates (text, reasoning, tools, tasks, tokens).
BaseStreamAdapter Object-oriented adapter hierarchy (OpenRouterStreamAdapter, GeminiStreamAdapter, OpenCodeStreamAdapter, AgUiStreamAdapter) translating provider events to normalized AG-UI protocol.
MessageBranch Dataclass encapsulating branch state (text, reasoning, tool calls, tokens) for reactive turn switching and forking.
ApprovalModal Ambient glassmorphism modal dialog for human-in-the-loop security gates.
ModelSelector Floating pill dropdown or inline composer selector for active model and reasoning effort.
VoicePill Audio streaming indicator and push-to-talk pill with animated waveforms.
AiMarkdown Markdown renderer that auto-converts fenced code into interactive CodeBlock components with incremental streaming.
LucideIcon Crisp outline SVG icon primitive matching contemporary AI developer tooling.

Run the interactive live demo showcasing end-to-end agent streaming with reasoning, tools, and queued steering:

uv run python -m nicegui_ai.demo

Or open the Component Gallery to inspect every single primitive across all its visual states:

uv run python -m nicegui_ai.gallery

Then open your browser at http://localhost:8080.


Development & Testing

# Run tests
uv run pytest

# Check formatting and linting
uv run ruff check .
uv run ruff format --check .

# Type checking (strict mode)
uv run mypy src/

License

MIT License. Designed for the Python AI agent community.

Metadata

Release files for nicegui-ai 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nicegui-ai 0.2.0
File Size Uploaded Provenance Actions
nicegui_ai-0.2.0.tar.gz 57.6 kB Without provenance Details for nicegui_ai-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nicegui-ai 0.2.0
File Interpreter ABI Platform Actions
nicegui_ai-0.2.0-py3-none-any.whl Python 3 none any Details for nicegui_ai-0.2.0-py3-none-any.whl

Total release size: 130.8 kB

Release files / nicegui_ai-0.2.0.tar.gz

Download URL nicegui_ai-0.2.0.tar.gz
Size 57.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bbbd949e78f46bc8b2cee0fb3d43c55100cb51419c66efe19528632c6f85b5cf
BLAKE2b-256 checksum
How to use checksums
9496d74db5a0aababd02f62864ea55c8ed28e7b952a5692ffcd883899dc1ab3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nicegui_ai-0.2.0-py3-none-any.whl

Download URL nicegui_ai-0.2.0-py3-none-any.whl
Size 73.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30912129f69797a3891fb88ef0b0f4c1076b737a70e7c9306f6c32c1547199ac
BLAKE2b-256 checksum
How to use checksums
b8573f8d555a59ba5067c64bed2aab842809a6431747d71fc7171886c108c9dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for nicegui-ai 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page