AG2 with PraisonAI
Low-code solution to run AG2 with integrated tools and features.
AutoGen is being evolved into AG2, check the new look here
Installation
# Install with AutoGen support
pip install "praisonai[autogen]"
This installation includes:
- AG2 framework
- PraisonAI tools integration
- Multi-agent conversation capabilities
- Code execution environment
Quick Start
# Set your OpenAI API key
export OPENAI_API_KEY=xxxxxxxxxx
# Initialize with AG2
praisonai --framework autogen --init "Create a Movie Script About Cat in Mars"
# Run the agents
praisonai --framework autogen
Auto Mode
praisonai --framework autogen --auto "Create a Movie Script About Cat in Mars"
AutoGen requires the roles format YAML (not the steps workflow format). Here’s the correct structure:
framework: autogen
topic: Create Movie Script About Cat in Mars
roles:
researcher:
role: Research Analyst
goal: Gather information about Mars and cats
backstory: Skilled in research, with a focus on gathering accurate and relevant information.
tasks:
research_task:
description: Research about Mars environment and cat behavior for the movie concept
expected_output: Research findings document with key facts
narrative_designer:
role: Story Concept Developer
goal: Create a story concept for a movie about a cat in Mars
backstory: Skilled in narrative development, with a focus on creating engaging stories.
tasks:
story_task:
description: Create story concept based on research findings
expected_output: Story concept with narrative arcs, character bios, and settings
scriptwriter:
role: Script Writer
goal: Write a movie script about a cat in Mars
backstory: Expert in dialogue and script structure, translating concepts into scripts.
tasks:
script_task:
description: Write the final movie script based on the story concept
expected_output: Production-ready movie script with dialogue and scene details
Important: The --framework autogen flag only works with YAML files using the roles format.The newer steps + agents workflow format only supports the praisonai framework and will ignore the --framework flag.
Running AutoGen
# Run with roles-format YAML
praisonai agents.yaml --framework autogen
# Or if framework is specified in YAML
praisonai agents.yaml
AutoGen Version Selection
PraisonAI supports both AutoGen v0.2 and v0.4. You can control which version to use:
# Use AutoGen v0.4 (default if available)
export AUTOGEN_VERSION=v0.4
praisonai agents.yaml --framework autogen
# Use AutoGen v0.2
export AUTOGEN_VERSION=v0.2
praisonai agents.yaml --framework autogen
# Auto-select (default: prefers v0.4)
export AUTOGEN_VERSION=auto
Framework Selection Priority
- CLI flag (
--framework autogen) takes precedence
- YAML file (
framework: autogen) is used if no CLI flag
- Default: praisonai framework
Direct Prompts
Direct prompts always use the praisonai framework regardless of the --framework flag:# This will use praisonai, NOT autogen
praisonai "What is 2+2?" --framework autogen
To use AutoGen, you must provide a YAML file with the roles format.