Skip to main content

Agent Example

If you're interested in using GPT Researcher as a standalone agent, you can easily import it into any existing Python project. Below, is an example of calling the agent to generate a research report:

from gpt_researcher import GPTResearcher
import asyncio

async def fetch_report(query):
"""
Fetch a research report based on the provided query and report type.
"""
researcher = GPTResearcher(query=query)
await researcher.conduct_research()
report = await researcher.write_report()
return report

async def generate_research_report(query):
"""
This is a sample script that executes an async main function to run a research report.
"""
report = await fetch_report(query)
print(report)

if __name__ == "__main__":
QUERY = "What happened in the latest burning man floods?"
asyncio.run(generate_research_report(query=QUERY))

You can further enhance this example to use the returned report as context for generating valuable content such as news article, marketing content, email templates, newsletters, etc.

You can also use GPT Researcher to gather information about code documentation, business analysis, financial information and more. All of which can be used to complete much more complex tasks that require factual and high quality realtime information.