# Python SDK API Reference for `import praisonaiui as aiui`. ## Server Configuration These functions configure the server. Call them at module level in your `app.py`, before the server starts. ### `aiui.set_style(style)` Set the UI style. | Parameter | Type | Values | |-----------|------|--------| | `style` | `str` | `"chat"`, `"dashboard"`, `"agents"`, `"playground"`, `"docs"`, `"custom"` | ```python aiui.set_style("dashboard") ``` Priority: `set_style()` → CLI `--style` flag → auto-detection. --- ### `aiui.set_pages(page_ids)` Whitelist which built-in sidebar pages to show (dashboard mode). Custom pages registered via `@aiui.page()` always appear. ```python aiui.set_pages([ "chat", "agents", "memory", "knowledge", "skills", "sessions", "usage", "config", "logs", ]) ``` Use `aiui pages ids` to see all available page IDs. --- ### `aiui.set_branding(title, logo)` Configure the sidebar branding (title text and logo emoji). | Parameter | Type | Default | |-----------|------|---------| | `title` | `str` | `"PraisonAI"` | | `logo` | `str` | `"🦞"` | ```python aiui.set_branding(title="MyApp", logo="🚀") ``` Also configurable via `config.yaml`: ```yaml site: title: MyApp logo: 🚀 ``` --- ### `aiui.set_datastore(store)` Set the persistence backend for sessions and messages. ```python # JSON file store (default) aiui.set_datastore(aiui.JSONFileDataStore()) # In-memory (no persistence) aiui.set_datastore(aiui.MemoryDataStore()) ``` --- ### `aiui.set_provider(provider)` Set the AI provider for chat completions. ```python aiui.set_provider(aiui.PraisonAIProvider()) ``` --- ### `aiui.register_agent(config)` Register an AI agent for the dashboard. Agents appear in the sidebar and can be selected for chat. ```python aiui.register_agent({ "agent_id": "researcher", "name": "Researcher", "description": "Research assistant", "instructions": "You are a research assistant.", "model": "gpt-4o-mini", "icon": "🔬", }) ``` --- ### `aiui.remove_page(page_id)` Remove a page from the sidebar. ```python aiui.remove_page("debug") ``` --- ### `aiui.set_chat_mode(mode, *, position, size, resizable, minimized)` Configure chat window display mode — full page, floating window, or sidebar panel. | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `mode` | `str` | `"fullpage"` | `"fullpage"`, `"floating"`, or `"sidebar"` | | `position` | `tuple[int, int]` | `(20, 20)` | (bottom, right) pixel offset for floating mode | | `size` | `tuple[int, int]` | `(400, 500)` | (width, height) initial size for floating mode | | `resizable` | `bool` | `True` | Allow resizing the floating window | | `minimized` | `bool` | `False` | Start minimized (floating mode only) | ```python import praisonaiui as aiui # Full page chat (default) aiui.set_chat_mode("fullpage") # Floating chat window aiui.set_chat_mode("floating", position=(20, 20), size=(420, 550)) # Sidebar panel aiui.set_chat_mode("sidebar") ``` --- ### `aiui.set_sidebar_config(*, collapsible, default_collapsed, width, min_width, max_width)` Configure sidebar behavior and dimensions. | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `collapsible` | `bool` | `True` | Allow sidebar to be collapsed | | `default_collapsed` | `bool` | `False` | Start with sidebar collapsed | | `width` | `int` | `260` | Default sidebar width in pixels | | `min_width` | `int` | `200` | Minimum width when resizing | | `max_width` | `int` | `360` | Maximum width when resizing | ```python import praisonaiui as aiui aiui.set_sidebar_config(collapsible=True, width=280) aiui.set_sidebar_config(default_collapsed=True) # Start collapsed ``` --- ### `aiui.set_brand_color(color)` Set the brand/primary accent color. Overrides the theme's default accent. | Parameter | Type | Description | |-----------|------|-------------| | `color` | `str` | Hex color (e.g. `"#6366f1"`) or CSS color value | ```python import praisonaiui as aiui aiui.set_brand_color("#818cf8") # Indigo-400 aiui.set_brand_color("#22c55e") # Green-500 ``` --- ### `aiui.set_chat_features(*, history, streaming, file_upload, audio, reasoning, tools, multimedia, feedback)` Configure which chat features are enabled in the UI. | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `history` | `bool` | `True` | Show session history sidebar | | `streaming` | `bool` | `True` | Enable streaming responses | | `file_upload` | `bool` | `False` | Show file upload button | | `audio` | `bool` | `False` | Show audio input button | | `reasoning` | `bool` | `True` | Show reasoning/thinking steps | | `tools` | `bool` | `True` | Show tool call displays | | `multimedia` | `bool` | `True` | Enable multimedia rendering | | `feedback` | `bool` | `False` | Show feedback buttons | ```python import praisonaiui as aiui # Minimal chat — no history sidebar, no file upload aiui.set_chat_features(history=False, file_upload=False) # Full-featured chat aiui.set_chat_features( history=True, streaming=True, file_upload=True, audio=True, feedback=True, ) ``` --- ### `aiui.set_dashboard(*, sidebar, page_header)` Configure dashboard layout options. | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `sidebar` | `bool` | `True` | Show the left sidebar navigation | | `page_header` | `bool` | `True` | Show the page title/description header | ```python import praisonaiui as aiui aiui.set_style("dashboard") aiui.set_dashboard(sidebar=False) # Chat-only dashboard, no sidebar aiui.set_dashboard(page_header=False) # Hide page titles ``` --- ### `aiui.set_chat_preview(enabled, *, surface_id, width)` Configure the **chat + canvas** split preview (`chat-canvas` page). The vanilla `chat` page is unchanged. | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `enabled` | `bool` | `True` | Expose preview settings in `/ui-config.json` | | `surface_id` | `str` | `"main"` | Default A2UI surface id for the preview panel | | `width` | `str` | `"40%"` | CSS width of the preview column (e.g. `"38%"`, `"420px"`) | ```python aiui.set_chat_preview(enabled=True, surface_id="main", width="38%") aiui.set_pages(["chat-canvas", "chat", "canvas"]) ``` See [A2UI canvas](../features/a2ui-canvas.md). --- ### `aiui.register_theme(name, variables)` Register a custom theme preset. The theme becomes available in the theme picker UI and via `/api/theme`. | Parameter | Type | Description | |-----------|------|-------------| | `name` | `str` | Unique theme name (e.g. `"ocean"`, `"sunset"`) | | `variables` | `dict[str, str]` | Dict with at least `{"accent": "#hexcolor"}` | ```python import praisonaiui as aiui # Register a custom theme aiui.register_theme("ocean", {"accent": "#0077b6"}) # With explicit RGB (auto-derived if omitted) aiui.register_theme("sunset", { "accent": "#ff6b35", "accentRgb": "255,107,53", }) # Apply the custom theme aiui.set_theme(preset="ocean") ``` See [CSS Architecture](../features/css-architecture.md) for all available CSS variables. --- ### `aiui.set_custom_js(path)` Inject a local JavaScript file into the UI. Reads the file at `path` and serves it at `/custom.js`. A `