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
# It is best to define global constants at the top of your script
QUERY = "What happened in the latest burning man floods?"
REPORT_TYPE = "research_report"
async def fetch_report(query, report_type):
"""
Fetch a research report based on the provided query and report type.
"""
researcher = GPTResearcher(query=query, report_type=report_type, config_path=None)
await researcher.conduct_research()
report = await researcher.write_report()
return report
async def generate_research_report():
"""
This is a sample script that executes an async main function to run a research report.
"""
report = await fetch_report(QUERY, REPORT_TYPE)
print(report)
if __name__ == "__main__":
asyncio.run(generate_research_report())
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.