(self, query: str)
| 19 | self.printer = Printer(self.console) |
| 20 | |
| 21 | async def run(self, query: str) -> None: |
| 22 | trace_id = gen_trace_id() |
| 23 | with trace("Research trace", trace_id=trace_id): |
| 24 | self.printer.update_item( |
| 25 | "trace_id", |
| 26 | f"View trace: https://platform.openai.com/traces/trace?trace_id={trace_id}", |
| 27 | is_done=True, |
| 28 | hide_checkmark=True, |
| 29 | ) |
| 30 | |
| 31 | self.printer.update_item( |
| 32 | "starting", |
| 33 | "Starting research...", |
| 34 | is_done=True, |
| 35 | hide_checkmark=True, |
| 36 | ) |
| 37 | search_plan = await self._plan_searches(query) |
| 38 | search_results = await self._perform_searches(search_plan) |
| 39 | report = await self._write_report(query, search_results) |
| 40 | |
| 41 | final_report = f"Report summary\n\n{report.short_summary}" |
| 42 | self.printer.update_item("final_report", final_report, is_done=True) |
| 43 | |
| 44 | self.printer.end() |
| 45 | |
| 46 | print("\n\n=====REPORT=====\n\n") |
| 47 | print(f"Report: {report.markdown_report}") |
| 48 | print("\n\n=====FOLLOW UP QUESTIONS=====\n\n") |
| 49 | follow_up_questions = "\n".join(report.follow_up_questions) |
| 50 | print(f"Follow up questions: {follow_up_questions}") |
| 51 | |
| 52 | async def _plan_searches(self, query: str) -> WebSearchPlan: |
| 53 | self.printer.update_item("planning", "Planning searches...") |
no test coverage detected