Files
PraisonAI/examples/python/input/medium_complexity_input.py
T
claude[bot]andMervin Praison 9f7993ac40 feat: add input variable value examples
- simple_input.py: Basic user input example
- medium_complexity_input.py: Multiple inputs with tools and context
- advanced_dynamic_input.py: Class-based system with conditional logic
- environment_variable_input.py: Combining env vars with user input
- streamlit_ui_input.py: Web-based UI for dynamic input

These examples demonstrate various approaches to handling dynamic user input in PraisonAI agents.

Closes #66

Co-authored-by: Mervin Praison <[email protected]>
2025-06-28 22:25:24 +00:00

55 lines
1.6 KiB
Python

"""
Medium Complexity Input Example for PraisonAI
This example shows how to use multiple user inputs to create a more sophisticated
agent system with tools, multiple agents, and context passing between tasks.
"""
from praisonaiagents import Agent, Task, PraisonAIAgents
from praisonaiagents.tools import duckduckgo
# Get multiple inputs
topic = input("Enter search topic: ")
num_results = input("How many results? (default: 5): ") or "5"
# Create search agent with tools
search_agent = Agent(
name="WebSearcher",
role="Search Specialist",
goal=f"Find {num_results} relevant results about {topic}",
backstory="Expert in internet research and data collection",
tools=[duckduckgo],
self_reflect=False
)
# Create analysis agent
analysis_agent = Agent(
name="Analyzer",
role="Data Analyst",
goal="Analyze and summarize search results",
backstory="Expert in data synthesis and reporting"
)
# Create tasks with context passing
search_task = Task(
description=f"Search for '{topic}' and find top {num_results} results",
expected_output=f"List of {num_results} relevant results with sources",
agent=search_agent,
name="search_task"
)
analyze_task = Task(
description="Analyze the search results and create a summary report",
expected_output="Comprehensive summary with key insights",
agent=analysis_agent,
context=[search_task], # Receives results from search_task
name="analysis_task"
)
# Run sequential process
agents = PraisonAIAgents(
agents=[search_agent, analysis_agent],
tasks=[search_task, analyze_task],
process="sequential"
)
agents.start()