22
33import asyncio
44
5- # with workflow.unsafe.imports_passed_through():
6- from rich .console import Console
5+ from temporalio import workflow
76
8- from agents import Runner , custom_span , gen_trace_id , trace , RunConfig
9-
10- from openai_agents .workflows .research_agents .planner_agent import WebSearchPlan , WebSearchItem , new_planner_agent
11- from openai_agents .workflows .research_agents .printer import Printer
12- from openai_agents .workflows .research_agents .search_agent import new_search_agent
13- from openai_agents .workflows .research_agents .writer_agent import ReportData , new_writer_agent
7+ with workflow .unsafe .imports_passed_through ():
8+ # TODO: Restore progress updates
9+ # from rich.console import Console
10+ from agents import Runner , custom_span , gen_trace_id , trace , RunConfig
11+ from openai_agents .workflows .research_agents .planner_agent import WebSearchPlan , WebSearchItem , new_planner_agent
12+ # from openai_agents.workflows.research_agents.printer import Printer
13+ from openai_agents .workflows .research_agents .search_agent import new_search_agent
14+ from openai_agents .workflows .research_agents .writer_agent import ReportData , new_writer_agent
1415
1516
1617class ResearchManager :
1718 def __init__ (self ):
18- self .console = Console ()
19- self .printer = Printer (self .console )
19+ # self.console = Console()
20+ # self.printer = Printer(self.console)
2021 self .run_config = RunConfig ()
2122 self .search_agent = new_search_agent ()
2223 self .planner_agent = new_planner_agent ()
@@ -26,27 +27,27 @@ def __init__(self):
2627 async def run (self , query : str ) -> str :
2728 trace_id = gen_trace_id ()
2829 with trace ("Research trace" , trace_id = trace_id ):
29- self .printer .update_item (
30- "trace_id" ,
31- f"View trace: https://platform.openai.com/traces/trace?trace_id={ trace_id } " ,
32- is_done = True ,
33- hide_checkmark = True ,
34- )
35-
36- self .printer .update_item (
37- "starting" ,
38- "Starting research..." ,
39- is_done = True ,
40- hide_checkmark = True ,
41- )
30+ # self.printer.update_item(
31+ # "trace_id",
32+ # f"View trace: https://platform.openai.com/traces/trace?trace_id={trace_id}",
33+ # is_done=True,
34+ # hide_checkmark=True,
35+ # )
36+
37+ # self.printer.update_item(
38+ # "starting",
39+ # "Starting research...",
40+ # is_done=True,
41+ # hide_checkmark=True,
42+ # )
4243 search_plan = await self ._plan_searches (query )
4344 search_results = await self ._perform_searches (search_plan )
4445 report = await self ._write_report (query , search_results )
4546
4647 final_report = f"Report summary\n \n { report .short_summary } "
47- self .printer .update_item ("final_report" , final_report , is_done = True )
48+ # self.printer.update_item("final_report", final_report, is_done=True)
4849
49- self .printer .end ()
50+ # self.printer.end()
5051
5152 print ("\n \n =====REPORT=====\n \n " )
5253 print (f"Report: { report .markdown_report } " )
@@ -57,23 +58,23 @@ async def run(self, query: str) -> str:
5758
5859
5960 async def _plan_searches (self , query : str ) -> WebSearchPlan :
60- self .printer .update_item ("planning" , "Planning searches..." )
61+ # self.printer.update_item("planning", "Planning searches...")
6162 result = await Runner .run (
6263 self .planner_agent ,
6364 f"Query: { query } " ,
6465 run_config = self .run_config ,
6566 )
66- self .printer .update_item (
67- "planning" ,
68- f"Will perform { len (result .final_output .searches )} searches" ,
69- is_done = True ,
70- )
67+ # self.printer.update_item(
68+ # "planning",
69+ # f"Will perform {len(result.final_output.searches)} searches",
70+ # is_done=True,
71+ # )
7172 return result .final_output_as (WebSearchPlan )
7273
7374
7475 async def _perform_searches (self , search_plan : WebSearchPlan ) -> list [str ]:
7576 with custom_span ("Search the web" ):
76- self .printer .update_item ("searching" , "Searching..." )
77+ # self.printer.update_item("searching", "Searching...")
7778 num_completed = 0
7879 tasks = [asyncio .create_task (self ._search (item )) for item in search_plan .searches ]
7980 results = []
@@ -82,10 +83,10 @@ async def _perform_searches(self, search_plan: WebSearchPlan) -> list[str]:
8283 if result is not None :
8384 results .append (result )
8485 num_completed += 1
85- self .printer .update_item (
86- "searching" , f"Searching... { num_completed } /{ len (tasks )} completed"
87- )
88- self .printer .mark_item_done ("searching" )
86+ # self.printer.update_item(
87+ # "searching", f"Searching... {num_completed}/{len(tasks)} completed"
88+ # )
89+ # self.printer.mark_item_done("searching")
8990 return results
9091
9192
@@ -103,7 +104,7 @@ async def _search(self, item: WebSearchItem) -> str | None:
103104
104105
105106 async def _write_report (self , query : str , search_results : list [str ]) -> ReportData :
106- self .printer .update_item ("writing" , "Thinking about report..." )
107+ # self.printer.update_item("writing", "Thinking about report...")
107108 input = f"Original query: { query } \n Summarized search results: { search_results } "
108109 result = await Runner .run (
109110 self .writer_agent ,
@@ -128,5 +129,5 @@ async def _write_report(self, query: str, search_results: list[str]) -> ReportDa
128129 # next_message += 1
129130 # last_update = time.time()
130131
131- self .printer .mark_item_done ("writing" )
132+ # self.printer.mark_item_done("writing")
132133 return result .final_output_as (ReportData )
0 commit comments