@@ -194,7 +194,6 @@ async def test_browser_use_parallel():
194
194
# api_key=os.getenv("OPENAI_API_KEY", ""),
195
195
# )
196
196
197
-
198
197
# llm = utils.get_llm_model(
199
198
# provider="google",
200
199
# model_name="gemini-2.0-flash",
@@ -335,6 +334,70 @@ async def test_browser_use_parallel():
335
334
await browser .close ()
336
335
337
336
337
+ async def test_deep_research_agent ():
338
+ from src .agent .deep_research .deep_research_agent import DeepSearchAgent
339
+ from src .utils import llm_provider
340
+
341
+ llm = llm_provider .get_llm_model (
342
+ provider = "azure_openai" ,
343
+ model_name = "gpt-4o" ,
344
+ temperature = 0.5 ,
345
+ base_url = os .getenv ("AZURE_OPENAI_ENDPOINT" , "" ),
346
+ api_key = os .getenv ("AZURE_OPENAI_API_KEY" , "" ),
347
+ )
348
+
349
+ mcp_server_config = {
350
+ "mcpServers" : {
351
+ "desktop-commander" : {
352
+ "command" : "npx" ,
353
+ "args" : [
354
+ "-y" ,
355
+ "@wonderwhy-er/desktop-commander"
356
+ ]
357
+ },
358
+ }
359
+ }
360
+
361
+ browser_config = {"headless" : False , "window_width" : 1280 , "window_height" : 1100 , "use_own_browser" : False }
362
+ agent = DeepSearchAgent (llm = llm , browser_config = browser_config , mcp_server_config = mcp_server_config )
363
+
364
+ research_topic = "Impact of Microplastics on Marine Ecosystems"
365
+ task_id_to_resume = None # Set this to resume a previous task ID
366
+
367
+ print (f"Starting research on: { research_topic } " )
368
+
369
+ try :
370
+ # Call run and wait for the final result dictionary
371
+ result = await agent .run (research_topic , task_id = task_id_to_resume )
372
+
373
+ print ("\n --- Research Process Ended ---" )
374
+ print (f"Status: { result .get ('status' )} " )
375
+ print (f"Message: { result .get ('message' )} " )
376
+ print (f"Task ID: { result .get ('task_id' )} " )
377
+
378
+ # Check the final state for the report
379
+ final_state = result .get ('final_state' , {})
380
+ if final_state :
381
+ print ("\n --- Final State Summary ---" )
382
+ print (
383
+ f" Plan Steps Completed: { sum (1 for item in final_state .get ('research_plan' , []) if item .get ('status' ) == 'completed' )} " )
384
+ print (f" Total Search Results Logged: { len (final_state .get ('search_results' , []))} " )
385
+ if final_state .get ("final_report" ):
386
+ print (" Final Report: Generated (content omitted). You can find it in the output directory." )
387
+ # print("\n--- Final Report ---") # Optionally print report
388
+ # print(final_state["final_report"])
389
+ else :
390
+ print (" Final Report: Not generated." )
391
+ else :
392
+ print ("Final state information not available." )
393
+
394
+
395
+ except Exception as e :
396
+ print (f"\n --- An unhandled error occurred outside the agent run ---" )
397
+ print (e )
398
+
399
+
338
400
if __name__ == "__main__" :
339
401
# asyncio.run(test_browser_use_agent())
340
- asyncio .run (test_browser_use_parallel ())
402
+ # asyncio.run(test_browser_use_parallel())
403
+ asyncio .run (test_deep_research_agent ())
0 commit comments