diff --git a/src/utils/deep_research.py b/src/utils/deep_research.py index c1c23e8..4cd2883 100644 --- a/src/utils/deep_research.py +++ b/src/utils/deep_research.py @@ -205,9 +205,16 @@ Provide your output as a JSON formatted list. Each item in the list must adhere ) agent_result = await agent.run(max_steps=kwargs.get("max_steps", 10)) query_results = [agent_result] + # Manually close all tab + session = await browser_context.get_session() + pages = session.context.pages + await browser_context.create_new_tab() + for page_id, page in enumerate(pages): + await page.close() + else: agents = [CustomAgent( - task=query_tasks[0], + task=query_tasks, llm=llm, add_infos=add_infos, browser=browser, @@ -244,7 +251,7 @@ Provide your output as a JSON formatted list. Each item in the list must adhere continue else: # TODO: limit content lenght: 128k tokens, ~3 chars per token - query_result_ = query_result_[:128000*3] + query_result_ = query_result_[:128000 * 3] history_infos_ = json.dumps(history_infos, indent=4) record_prompt = f"User Instruction:{task}. \nPrevious Recorded Information:\n {history_infos_}\n Current Search Iteration: {search_iteration}\n Current Search Plan:\n{query_plan}\n Current Search Query:\n {query_tasks[i]}\n Current Search Results: {query_result_}\n " record_messages.append(HumanMessage(content=record_prompt)) diff --git a/webui.py b/webui.py index 3b7906d..8e9d6b2 100644 --- a/webui.py +++ b/webui.py @@ -850,8 +850,8 @@ def create_ui(config, theme_name="Ocean"): with gr.TabItem("🧐 Deep Research", id=5): research_task_input = gr.Textbox(label="Research Task", lines=5, value="Compose a report on the use of Reinforcement Learning for training Large Language Models, encompassing its origins, current advancements, and future prospects, substantiated with examples of relevant models and techniques. The report should reflect original insights and analysis, moving beyond mere summarization of existing literature.") with gr.Row(): - max_search_iteration_input = gr.Number(label="Max Search Iteration", value=20, precision=0) # precision=0 确保是整数 - max_query_per_iter_input = gr.Number(label="Max Query per Iteration", value=5, precision=0) # precision=0 确保是整数 + max_search_iteration_input = gr.Number(label="Max Search Iteration", value=3, precision=0) # precision=0 确保是整数 + max_query_per_iter_input = gr.Number(label="Max Query per Iteration", value=1, precision=0) # precision=0 确保是整数 with gr.Row(): research_button = gr.Button("▶️ Run Deep Research", variant="primary", scale=2) stop_research_button = gr.Button("⏹️ Stop", variant="stop", scale=1)