mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 04:35:58 -10:00
Remove deprecated parameters from examples and fix Agent initialization
- Remove `verbose` parameter from Agents() calls across all examples - Remove `markdown` parameter from Agent() initialization - Change `model` to `llm` in observability example - Remove unused `kind` parameter from obs.span() - Fix thinking_budget initialization to use property setter instead of constructor - Add missing `instructions` parameter to routellm_example.py Agent
This commit is contained in:
1 parent
0b4b96f4c2
commit
83ca07a9a9
22 files changed
+8
-44
No files matched your search
@@ -24,13 +24,13 @@ obs.init()
|
||||
# Create an agent
|
||||
agent = Agent(
|
||||
instructions="You are a helpful assistant.",
|
||||
model="gpt-4o-mini",
|
||||
llm="gpt-4o-mini",
|
||||
)
|
||||
|
||||
# Use trace context manager for complete workflow tracing
|
||||
with obs.trace("chat-session", session_id="user-123"):
|
||||
# Use span context manager for individual operations
|
||||
with obs.span("user-query", kind=obs.SpanKind.AGENT):
|
||||
with obs.span("user-query"):
|
||||
response = agent.chat("What is the capital of France?")
|
||||
print(response)
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ agents = Agents(
|
||||
agents=[image_agent],
|
||||
tasks=[task1, task2],
|
||||
process="sequential",
|
||||
verbose=1
|
||||
)
|
||||
|
||||
# Run all tasks
|
||||
|
||||
@@ -40,7 +40,6 @@ agents = Agents(
|
||||
agents=[image_agent],
|
||||
tasks=[task1, task2],
|
||||
process="sequential",
|
||||
verbose=1
|
||||
)
|
||||
|
||||
# Run all tasks
|
||||
|
||||
@@ -29,7 +29,6 @@ agents = Agents(
|
||||
agents=[video_agent],
|
||||
tasks=[task1],
|
||||
process="sequential",
|
||||
verbose=1
|
||||
)
|
||||
|
||||
# Run all tasks
|
||||
|
||||
@@ -62,7 +62,6 @@ def capture_and_analyze():
|
||||
agents=[vision_agent],
|
||||
tasks=[task],
|
||||
process="sequential",
|
||||
verbose=1
|
||||
)
|
||||
|
||||
result = agents.start()
|
||||
|
||||
@@ -118,7 +118,6 @@ def analyze_with_multiple_agents():
|
||||
agents=[security_agent, object_detector, scene_analyst],
|
||||
tasks=[security_task, object_task, scene_task],
|
||||
process="parallel", # Run all analyses in parallel
|
||||
verbose=1
|
||||
)
|
||||
|
||||
result = agents.start()
|
||||
|
||||
@@ -135,7 +135,6 @@ class CameraVideoAnalyzer:
|
||||
agents=[self.video_agent],
|
||||
tasks=[task],
|
||||
process="sequential",
|
||||
verbose=1
|
||||
)
|
||||
|
||||
return agents.start()
|
||||
|
||||
@@ -99,7 +99,6 @@ sync_agent = Agent(
|
||||
backstory="Expert in sync operations and data organization",
|
||||
tools=[sync_search_tool],
|
||||
reflection=False,
|
||||
markdown=True
|
||||
)
|
||||
|
||||
async_agent = Agent(
|
||||
@@ -109,7 +108,6 @@ async_agent = Agent(
|
||||
backstory="Expert in async operations and data organization",
|
||||
tools=[async_search_tool],
|
||||
reflection=False,
|
||||
markdown=True
|
||||
)
|
||||
|
||||
# 5. Create tasks with different configurations
|
||||
@@ -161,7 +159,6 @@ def run_sync_example():
|
||||
agents = Agents(
|
||||
agents=[sync_agent],
|
||||
tasks=[sync_task],
|
||||
verbose=1,
|
||||
process="sequential"
|
||||
)
|
||||
result = agents.start()
|
||||
@@ -173,7 +170,6 @@ async def run_async_example():
|
||||
agents = Agents(
|
||||
agents=[async_agent],
|
||||
tasks=[async_task],
|
||||
verbose=1,
|
||||
process="sequential"
|
||||
)
|
||||
result = await agents.astart()
|
||||
@@ -185,7 +181,6 @@ async def run_mixed_example():
|
||||
agents = Agents(
|
||||
agents=[sync_agent, async_agent],
|
||||
tasks=[sync_task, async_task],
|
||||
verbose=1,
|
||||
process="sequential"
|
||||
)
|
||||
result = await agents.astart()
|
||||
@@ -197,7 +192,6 @@ async def run_workflow_example():
|
||||
agents = Agents(
|
||||
agents=[sync_agent, async_agent],
|
||||
tasks=[workflow_sync_task, workflow_async_task],
|
||||
verbose=1,
|
||||
process="workflow"
|
||||
)
|
||||
result = await agents.astart()
|
||||
|
||||
@@ -54,7 +54,6 @@ async_agent = Agent(
|
||||
backstory="Expert in efficient data retrieval and parallel search operations",
|
||||
tools=[async_search_tool],
|
||||
reflection=False,
|
||||
markdown=True
|
||||
)
|
||||
|
||||
summary_agent = Agent(
|
||||
@@ -63,7 +62,6 @@ summary_agent = Agent(
|
||||
goal="Create concise summaries from multiple search results",
|
||||
backstory="Expert in analyzing and synthesizing information from multiple sources",
|
||||
reflection=True,
|
||||
markdown=True
|
||||
)
|
||||
|
||||
# 5. Create async tasks
|
||||
@@ -116,7 +114,6 @@ async def run_parallel_tasks():
|
||||
agents = Agents(
|
||||
agents=[async_agent, summary_agent],
|
||||
tasks=parallel_tasks + [summary_task],
|
||||
verbose=1,
|
||||
process="sequential"
|
||||
)
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ async_agent = Agent(
|
||||
backstory="Expert in parallel search operations and data retrieval",
|
||||
tools=[async_search_tool],
|
||||
reflection=False,
|
||||
markdown=True
|
||||
)
|
||||
|
||||
summary_agent = Agent(
|
||||
@@ -72,7 +71,6 @@ summary_agent = Agent(
|
||||
Skilled at identifying patterns, trends, and connections between different topics.
|
||||
Specializes in creating clear, structured summaries that highlight key insights.""",
|
||||
reflection=True, # Enable self-reflection for better summary quality
|
||||
markdown=True
|
||||
)
|
||||
|
||||
# 5. Create async tasks
|
||||
@@ -104,7 +102,6 @@ async def run_single_task():
|
||||
agents = Agents(
|
||||
agents=[async_agent],
|
||||
tasks=[async_task],
|
||||
verbose=1,
|
||||
process="sequential"
|
||||
)
|
||||
result = await agents.astart()
|
||||
@@ -188,7 +185,6 @@ Present the summary in a clear, structured format with sections for findings, pa
|
||||
agents = Agents(
|
||||
agents=[async_agent],
|
||||
tasks=parallel_tasks, # Only run search tasks first
|
||||
verbose=1,
|
||||
process="sequential"
|
||||
)
|
||||
search_results = await agents.astart()
|
||||
@@ -213,7 +209,6 @@ Present the summary in a clear, structured format with sections for findings, pa
|
||||
summary_agents = Agents(
|
||||
agents=[summary_agent], # Use summary agent for synthesis
|
||||
tasks=[summary_task],
|
||||
verbose=1,
|
||||
process="sequential"
|
||||
)
|
||||
summary_result = await summary_agents.astart()
|
||||
|
||||
@@ -127,10 +127,6 @@ def main():
|
||||
allow_delegation=False,
|
||||
tools=[internet_search_tool],
|
||||
llm="gpt-4o-mini",
|
||||
markdown=True,
|
||||
|
||||
|
||||
|
||||
)
|
||||
|
||||
writer = Agent(
|
||||
@@ -142,7 +138,6 @@ def main():
|
||||
allow_delegation=True,
|
||||
llm="gpt-4o-mini",
|
||||
tools=[],
|
||||
markdown=True
|
||||
)
|
||||
|
||||
# Create tasks with callbacks
|
||||
|
||||
@@ -144,7 +144,6 @@ validate_task = Task(
|
||||
agents = Agents(
|
||||
agents=[data_agent],
|
||||
tasks=[collect_task, validate_task],
|
||||
verbose=1,
|
||||
process="workflow"
|
||||
)
|
||||
|
||||
|
||||
@@ -39,10 +39,6 @@ researcher = Agent(
|
||||
allow_delegation=False,
|
||||
tools=[internet_search_tool],
|
||||
llm="gpt-4o-mini",
|
||||
markdown=True,
|
||||
|
||||
|
||||
|
||||
)
|
||||
writer = Agent(
|
||||
name="Writer",
|
||||
@@ -53,7 +49,6 @@ writer = Agent(
|
||||
allow_delegation=True,
|
||||
llm="gpt-4o-mini",
|
||||
tools=[],
|
||||
markdown=True
|
||||
)
|
||||
|
||||
# Create tasks
|
||||
|
||||
@@ -46,8 +46,7 @@ task3 = Task(
|
||||
agents = Agents(
|
||||
agents=[vision_agent],
|
||||
tasks=[task1, task2, task3],
|
||||
process="sequential",
|
||||
verbose=1
|
||||
process="sequential"
|
||||
)
|
||||
|
||||
# Run all tasks
|
||||
|
||||
@@ -32,9 +32,7 @@ def get_structured_analysis(query: str, verbose: bool = True) -> AnalysisReport:
|
||||
role="Research Analyst",
|
||||
goal="Analyze topics and provide structured reports",
|
||||
backstory="Expert at gathering information and providing structured analysis",
|
||||
verbose=verbose,
|
||||
reflection=True, # Enable self-reflection for better quality
|
||||
markdown=True,
|
||||
llm="gpt-4o-mini"
|
||||
)
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ validate_task = Task(
|
||||
agents = Agents(
|
||||
agents=[data_agent],
|
||||
tasks=[collect_task, validate_task],
|
||||
verbose=1,
|
||||
process="workflow"
|
||||
)
|
||||
|
||||
|
||||
@@ -228,7 +228,6 @@ process_task = Task(
|
||||
workflow = Agents(
|
||||
agents=[data_agent, process_agent],
|
||||
tasks=[collect_task, validate_task, process_task],
|
||||
verbose=1,
|
||||
process="workflow"
|
||||
)
|
||||
|
||||
|
||||
@@ -152,7 +152,6 @@ def main():
|
||||
agents_system = Agents(
|
||||
agents=[researcher],
|
||||
tasks=[build_knowledge_task, query_knowledge_task, expand_knowledge_task],
|
||||
verbose=1,
|
||||
memory=True,
|
||||
memory_config=memory_config
|
||||
)
|
||||
|
||||
@@ -91,7 +91,6 @@ def main():
|
||||
memory=True,
|
||||
process="workflow",
|
||||
user_id="research_project_001",
|
||||
verbose=1
|
||||
)
|
||||
|
||||
print(f"🤖 Created workflow with {len(workflow.agents)} agents and {len(workflow.tasks)} tasks")
|
||||
|
||||
@@ -51,7 +51,6 @@ def basic_rag_example():
|
||||
|
||||
COMPANY DATABASE:
|
||||
{context}""",
|
||||
verbose=False
|
||||
)
|
||||
|
||||
# Test queries
|
||||
|
||||
@@ -18,6 +18,7 @@ from praisonaiagents import Agent
|
||||
|
||||
# Basic usage with RouteLLM routing
|
||||
agent = Agent(
|
||||
instructions="You are a helpful assistant.",
|
||||
llm="router-mf-0.5",
|
||||
base_url="http://localhost:6060/v1"
|
||||
)
|
||||
|
||||
@@ -45,8 +45,9 @@ def main():
|
||||
agent = Agent(
|
||||
name="DeepThinker",
|
||||
instructions="You are a problem-solving assistant that thinks step by step.",
|
||||
thinking_budget=ThinkingBudget.high() # 16,000 tokens for reasoning
|
||||
)
|
||||
# Set thinking budget via property setter (not constructor param)
|
||||
agent.thinking_budget = ThinkingBudget.high() # 16,000 tokens for reasoning
|
||||
|
||||
print(f"Agent: {agent.name}")
|
||||
print(f"Thinking budget: {agent.thinking_budget.max_tokens:,} tokens")
|
||||
@@ -67,8 +68,9 @@ def main():
|
||||
agent_custom = Agent(
|
||||
name="CustomThinker",
|
||||
instructions="You solve complex problems.",
|
||||
thinking_budget=custom_budget
|
||||
)
|
||||
# Set thinking budget via property setter (not constructor param)
|
||||
agent_custom.thinking_budget = custom_budget
|
||||
|
||||
print(f"Agent: {agent_custom.name}")
|
||||
print(f"Max tokens: {agent_custom.thinking_budget.max_tokens:,}")
|
||||
|
||||
Reference in new issue
Block a user