Skip to main content

display

Rust AI Agent SDK Display and callback system for PraisonAI This module provides display functions and callback registration matching the Python SDK’s main.py display system.

Features

  • Display functions for various output types (interaction, tool calls, errors, etc.)
  • Callback registration for custom display handling
  • Approval callback for dangerous operations
  • Color palette for consistent UI

Example

use praisonai::display::{register_display_callback, display_interaction, DisplayType};

// Register a custom callback
register_display_callback(DisplayType::Interaction, |event| {
println!("Agent: {} said: {}", event.agent_name, event.content);
});

// Display an interaction
display_interaction("assistant", "Hello!", None);

Import

use praisonai::display::*;

Classes

ColorPalette

PraisonAI color palette for consistent UI

DisplayEvent

Event data passed to display callbacks

DisplayType

Types of display events

ApprovalDecision

Approval decision for dangerous operations

RiskLevel

Risk level for operations requiring approval

Functions

clear_display_callbacks()

Clear all callbacks for a display type

clear_all_callbacks()

Clear all callbacks

execute_sync_callbacks()

Execute synchronous callbacks for a display event

execute_async_callbacks()

Execute asynchronous callbacks for a display event

execute_callbacks()

Execute all callbacks (sync and async) for a display event

request_approval()

Request approval for a dangerous operation

display_interaction()

Display an agent interaction

display_instruction()

Display an instruction

display_tool_call()

Display a tool call

display_error()

Display an error

display_generating()

Display generating/working status

display_reasoning_steps()

Display reasoning steps

display_working_status()

Display working status with animation frame

display_self_reflection()

Display self-reflection output

clean_display_content()

Clean content for display (truncate if too long)

has_callbacks()

Check if callbacks are registered for a display type

callback_count()

Get the number of registered callbacks for a display type

Rust Display

Rust Output