assafelovic / gpt-researcher

LLM based autonomous agent that does online comprehensive research on any given topic
https://gptr.dev
Apache License 2.0
14.25k stars 1.86k forks source link

access to the researcher.conduct_research() data #549

Closed theguaz closed 4 months ago

theguaz commented 4 months ago

When executing directly the example:

`... from gpt_researcher import GPTResearcher

query = "why is Nvidia stock going up?" researcher = GPTResearcher(query=query, report_type="research_report")

Conduct research on the given query

research_result = await researcher.conduct_research()

Write the report

report = await researcher.write_report() ...`

is there any way to save the contents of the researcher.conduct_research() like we can do it with the researcher.write_report()?

theguaz commented 4 months ago

I wrote this and it worked :

` conduct_research = await researcher.conduct_research() report = await researcher.write_report()

Write the report to a file

uuid = uuid4()
artifact_filepath_1 = f"outputs/report_{get_formatted_date_time()}_{uuid}.md"
with open(artifact_filepath_1, "w") as f:
    f.write(report)
# Write the research to a file
artifact_filepath_2 = f"outputs/research_{get_formatted_date_time()}_{uuid}.md"
with open(artifact_filepath_2, "w") as f:
    f.write(str( conduct_research ) )`