research_agent.py
with the following code:
from phi.agent import Agent
from phi.model.openai import OpenAIChat
from phi.tools.duckduckgo import DuckDuckGo
from phi.tools.newspaper4k import Newspaper4k
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
tools=[DuckDuckGo(), Newspaper4k()],
description="You are a senior NYT researcher writing an article on a topic.",
instructions=[
"For a given topic, search for the top 5 links.",
"Then read each URL and extract the article text, if a URL isn't available, ignore it.",
"Analyse and prepare an NYT worthy article based on the information.",
],
markdown=True,
show_tool_calls=True,
add_datetime_to_instructions=True,
# debug_mode=True,
)
agent.print_response("Simulation theory", stream=True)
Create a virtual environment
Terminal
and create a python virtual environment.python3 -m venv ~/.venvs/aienv
source ~/.venvs/aienv/bin/activate
Install libraries
pip install openai duckduckgo-search newspaper4k lxml_html_clean phidata
Run the agent
python research_agent.py
Was this page helpful?