Skip to main content

ChainlitUI Module

The ChainlitUI module provides a Chainlit-based user interface for interacting with PraisonAI agents.

Prerequisites

pip install chainlit

Import

from praisonai.chainlit_ui import *

Quick Start

  1. Create a chainlit_app.py file:
from praisonai.chainlit_ui import *
  1. Run with Chainlit:
chainlit run chainlit_app.py

Features

Chat Profiles

The UI supports multiple chat profiles:
  • Auto: Automatically generate agents and tasks based on input
  • Manual: Configure agents manually from YAML

Starter Prompts

Pre-configured starter prompts for common use cases:
  • Create a movie script
  • Design a fantasy world
  • Write a futuristic political thriller
  • Develop a mystery novel
  • Plan a sci-fi adventure

Configuration

Environment Variables

VariableDescriptionDefault
OPENAI_MODEL_NAMEModel to usegpt-4o-mini
OPENAI_API_BASEAPI base URLhttps://api.openai.com/v1
OPENAI_API_KEYAPI keyRequired

Agent Configuration

Configure agents via agents.yaml:
agents:
  - name: Researcher
    role: Research Specialist
    goal: Research topics thoroughly
    tools:
      - web_search
      
  - name: Writer
    role: Content Writer
    goal: Write engaging content
    
tasks:
  - agent: Researcher
    task: Research the given topic
  - agent: Writer
    task: Write content based on research

Actions

Run Action

Execute the configured agents with the current input.

Modify Action

Modify agents and tools from the settings panel.

Example: Custom Chainlit App

import chainlit as cl
from praisonai.agents_generator import AgentsGenerator
from praisonai.auto import AutoGenerator

@cl.on_chat_start
async def start():
    await cl.Message(
        content="Welcome to PraisonAI! What would you like to create?"
    ).send()

@cl.on_message
async def main(message: cl.Message):
    # Auto-generate agents based on user input
    generator = AutoGenerator(topic=message.content)
    agents_config = generator.generate()
    
    # Run the agents
    agents = AgentsGenerator(agents_config)
    result = agents.run()
    
    await cl.Message(content=result).send()

Chat Settings

Configure via the Chainlit settings panel:
  • Framework: Choose between CrewAI, AutoGen, or PraisonAI
  • Model: Select the LLM model
  • Agent File: Path to agents.yaml configuration