/ examples / basic / multi_step_research.py
multi_step_research.py
 1  """Multi-Step Research - Editor Output Example.
 2  
 3  Researches Python frameworks, creates comparison code, runs it, writes a
 4  markdown report, reads it back, lists files, and gets system info.
 5  """
 6  from praisonaiagents import Agent
 7  from praisonaiagents.tools import (
 8      write_file, read_file, execute_command, list_files, get_system_info
 9  )
10  
11  try:
12      from praisonaiagents.tools import web_search
13      tools = [web_search, write_file, read_file, execute_command,
14               list_files, get_system_info]
15  except ImportError:
16      tools = [write_file, read_file, execute_command,
17               list_files, get_system_info]
18  
19  agent = Agent(
20      instructions="You are a helpful research assistant.",
21      output="editor",
22      tools=tools,
23      approval=False,
24  )
25  agent.start(
26      "Research the top 3 Python web frameworks (Django, FastAPI, Flask), then: "
27      "1) Search the web for each framework's latest version and key features, "
28      "2) Create a file called /tmp/framework_comparison.py that contains a "
29      "Python dictionary with the comparison data, "
30      "3) Execute the code to verify the dictionary is valid, "
31      "4) Write a markdown report to /tmp/framework_report.md summarizing your "
32      "findings in a table format, "
33      "5) Read back the report file to verify it was written correctly, "
34      "6) List the files in /tmp to confirm both files exist, "
35      "7) Get system info to note what OS this report was generated on"
36  )