DeepResearchAgent#
DeepResearchAgent helps break down complex tasks into smaller steps, using web scraping and other techniques to find the information you need. Instead of handling everything at once, it tackles each part step by step, making research easier and more efficient. Whether you’re looking for specific details, gathering data, or just trying to solve a tricky problem, this agent does the heavy lifting for you.
Installation#
Note: DeepResearchAgent is built on top of Browser Use, which requires Python 3.11 or higher.
To get started with the DeepResearchAgent agent, follow these steps:
-
Install AG2 with the
browser-useextra:Note: If you have been using
autogenorpyautogen, all you need to do is upgrade it using:or
as
pyautogen,autogen, andag2are aliases for the same PyPI package. -
Set up Playwright:
-
For running the code in Jupyter, use
nest_asyncioto allow nested event loops.bash pip install nest_asyncio
You’re all set! Now you can start solving complex tasks.
Imports#
import os
import nest_asyncio
from autogen.agents.experimental import DeepResearchAgent
nest_asyncio.apply()
Starting the Conversation#
This code initializes DeepResearchAgent and asks it to find out What was the impact of DeepSeek on stock prices and why? using GPT-4o.
Note: Models like
gpt-4o-minioften don’t perform well enough for complex tasks.
llm_config = {
"config_list": [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}],
}
agent = DeepResearchAgent(
name="DeepResearchAgent",
llm_config=llm_config,
)
message = "What was the impact of DeepSeek on stock prices and why?"
run_result = agent.run(
message=message,
tools=agent.tools,
max_turns=2,
user_input=False,
summary_method="reflection_with_llm",
)
run_result.process()
run_result.summary