I encountered an issue with the write_report method in the gpt-researcher library. When the report_type is set to custom_report, the report variable is not instantiated, which leads to the following error:
Error while writing report: local variable 'report' referenced before assignment
Reproduction Steps:
Set report_type to custom_report.
Call the write_report method.
Observe the error indicating that the report variable is referenced before assignment.
Code Snippet:
Here is the relevant portion of the code:
async def write_report(self, existing_headers: list = []):
"""
Writes the report based on research conducted
I encountered an issue with the write_report method in the gpt-researcher library. When the report_type is set to custom_report, the report variable is not instantiated, which leads to the following error:
Error while writing report: local variable 'report' referenced before assignment
Reproduction Steps:
Code Snippet: Here is the relevant portion of the code:
async def write_report(self, existing_headers: list = []): """ Writes the report based on research conducted
Suggested Fix: Include a call to generate_report in the custom_report block to ensure report is always assigned. For example:
if self.report_type == "custom_report": self.role = self.cfg.agent_role if self.cfg.agent_role else self.role report = await generate_report( query=self.query, context=self.context, agent_role_prompt=self.role, report_type=self.report_type, report_source=self.report_source, websocket=self.websocket, cfg=self.cfg )
Thank you for looking into this issue!