戒酒的李白

At the same time, activate the search function to achieve.

@@ -47,42 +47,33 @@ def main(): @@ -47,42 +47,33 @@ def main():
47 max_reflections = 2 47 max_reflections = 2
48 max_content_length = 500000 # Kimi支持长文本 48 max_content_length = 500000 # Kimi支持长文本
49 49
50 - # 主界面  
51 - col1, col2 = st.columns([2, 1])  
52 -  
53 - with col1: 50 + # 简化的研究查询展示区域
54 st.header("研究查询") 51 st.header("研究查询")
55 52
56 - # 如果有自动查询,使用它作为默认值  
57 - default_query = auto_query if auto_query else "" 53 + # 如果有自动查询,使用它作为默认值,否则显示占位符
  54 + display_query = auto_query if auto_query else "等待从主页面接收搜索查询..."
58 55
59 - query = st.text_area(  
60 - "请输入您要研究的问题",  
61 - value=default_query,  
62 - placeholder="例如:2025年人工智能发展趋势",  
63 - height=100 56 + # 只读的查询展示区域
  57 + st.text_area(
  58 + "当前查询",
  59 + value=display_query,
  60 + height=100,
  61 + disabled=True,
  62 + help="查询内容由主页面的搜索框控制"
64 ) 63 )
65 64
66 - with col2:  
67 - st.header("状态信息")  
68 - if 'agent' in st.session_state and hasattr(st.session_state.agent, 'state'):  
69 - progress = st.session_state.agent.get_progress_summary()  
70 - st.metric("总段落数", progress['total_paragraphs'])  
71 - st.metric("已完成", progress['completed_paragraphs'])  
72 - st.progress(progress['progress_percentage'] / 100)  
73 - else:  
74 - st.info("尚未开始研究")  
75 -  
76 - # 执行按钮  
77 - col1_btn, col2_btn, col3_btn = st.columns([1, 1, 1])  
78 - with col2_btn:  
79 - start_research = st.button("开始研究", type="primary", use_container_width=True)  
80 -  
81 # 自动搜索逻辑 65 # 自动搜索逻辑
  66 + start_research = False
  67 + query = auto_query
  68 +
82 if auto_search and auto_query and 'auto_search_executed' not in st.session_state: 69 if auto_search and auto_query and 'auto_search_executed' not in st.session_state:
83 st.session_state.auto_search_executed = True 70 st.session_state.auto_search_executed = True
84 start_research = True 71 start_research = True
85 - query = auto_query 72 + st.success(f"🚀 接收到搜索请求:{auto_query}")
  73 + st.info("正在启动研究...")
  74 + elif auto_query and not auto_search:
  75 + st.info(f"📝 当前查询:{auto_query}")
  76 + st.warning("等待搜索启动信号...")
86 77
87 # 验证配置 78 # 验证配置
88 if start_research: 79 if start_research:
@@ -47,42 +47,33 @@ def main(): @@ -47,42 +47,33 @@ def main():
47 max_reflections = 2 47 max_reflections = 2
48 max_content_length = 20000 48 max_content_length = 20000
49 49
50 - # 主界面  
51 - col1, col2 = st.columns([2, 1])  
52 -  
53 - with col1: 50 + # 简化的研究查询展示区域
54 st.header("研究查询") 51 st.header("研究查询")
55 52
56 - # 如果有自动查询,使用它作为默认值  
57 - default_query = auto_query if auto_query else "" 53 + # 如果有自动查询,使用它作为默认值,否则显示占位符
  54 + display_query = auto_query if auto_query else "等待从主页面接收搜索查询..."
58 55
59 - query = st.text_area(  
60 - "请输入您要研究的问题",  
61 - value=default_query,  
62 - placeholder="例如:2025年人工智能发展趋势",  
63 - height=100 56 + # 只读的查询展示区域
  57 + st.text_area(
  58 + "当前查询",
  59 + value=display_query,
  60 + height=100,
  61 + disabled=True,
  62 + help="查询内容由主页面的搜索框控制"
64 ) 63 )
65 64
66 - with col2:  
67 - st.header("状态信息")  
68 - if 'agent' in st.session_state and hasattr(st.session_state.agent, 'state'):  
69 - progress = st.session_state.agent.get_progress_summary()  
70 - st.metric("总段落数", progress['total_paragraphs'])  
71 - st.metric("已完成", progress['completed_paragraphs'])  
72 - st.progress(progress['progress_percentage'] / 100)  
73 - else:  
74 - st.info("尚未开始研究")  
75 -  
76 - # 执行按钮  
77 - col1_btn, col2_btn, col3_btn = st.columns([1, 1, 1])  
78 - with col2_btn:  
79 - start_research = st.button("开始研究", type="primary", use_container_width=True)  
80 -  
81 # 自动搜索逻辑 65 # 自动搜索逻辑
  66 + start_research = False
  67 + query = auto_query
  68 +
82 if auto_search and auto_query and 'auto_search_executed' not in st.session_state: 69 if auto_search and auto_query and 'auto_search_executed' not in st.session_state:
83 st.session_state.auto_search_executed = True 70 st.session_state.auto_search_executed = True
84 start_research = True 71 start_research = True
85 - query = auto_query 72 + st.success(f"🚀 接收到搜索请求:{auto_query}")
  73 + st.info("正在启动研究...")
  74 + elif auto_query and not auto_search:
  75 + st.info(f"📝 当前查询:{auto_query}")
  76 + st.warning("等待搜索启动信号...")
86 77
87 # 验证配置 78 # 验证配置
88 if start_research: 79 if start_research:
@@ -47,42 +47,33 @@ def main(): @@ -47,42 +47,33 @@ def main():
47 max_reflections = 2 47 max_reflections = 2
48 max_content_length = 20000 48 max_content_length = 20000
49 49
50 - # 主界面  
51 - col1, col2 = st.columns([2, 1])  
52 -  
53 - with col1: 50 + # 简化的研究查询展示区域
54 st.header("研究查询") 51 st.header("研究查询")
55 52
56 - # 如果有自动查询,使用它作为默认值  
57 - default_query = auto_query if auto_query else "" 53 + # 如果有自动查询,使用它作为默认值,否则显示占位符
  54 + display_query = auto_query if auto_query else "等待从主页面接收搜索查询..."
58 55
59 - query = st.text_area(  
60 - "请输入您要研究的问题",  
61 - value=default_query,  
62 - placeholder="例如:2025年人工智能发展趋势",  
63 - height=100 56 + # 只读的查询展示区域
  57 + st.text_area(
  58 + "当前查询",
  59 + value=display_query,
  60 + height=100,
  61 + disabled=True,
  62 + help="查询内容由主页面的搜索框控制"
64 ) 63 )
65 64
66 - with col2:  
67 - st.header("状态信息")  
68 - if 'agent' in st.session_state and hasattr(st.session_state.agent, 'state'):  
69 - progress = st.session_state.agent.get_progress_summary()  
70 - st.metric("总段落数", progress['total_paragraphs'])  
71 - st.metric("已完成", progress['completed_paragraphs'])  
72 - st.progress(progress['progress_percentage'] / 100)  
73 - else:  
74 - st.info("尚未开始研究")  
75 -  
76 - # 执行按钮  
77 - col1_btn, col2_btn, col3_btn = st.columns([1, 1, 1])  
78 - with col2_btn:  
79 - start_research = st.button("开始研究", type="primary", use_container_width=True)  
80 -  
81 # 自动搜索逻辑 65 # 自动搜索逻辑
  66 + start_research = False
  67 + query = auto_query
  68 +
82 if auto_search and auto_query and 'auto_search_executed' not in st.session_state: 69 if auto_search and auto_query and 'auto_search_executed' not in st.session_state:
83 st.session_state.auto_search_executed = True 70 st.session_state.auto_search_executed = True
84 start_research = True 71 start_research = True
85 - query = auto_query 72 + st.success(f"🚀 接收到搜索请求:{auto_query}")
  73 + st.info("正在启动研究...")
  74 + elif auto_query and not auto_search:
  75 + st.info(f"📝 当前查询:{auto_query}")
  76 + st.warning("等待搜索启动信号...")
86 77
87 # 验证配置 78 # 验证配置
88 if start_research: 79 if start_research:
@@ -400,32 +400,20 @@ @@ -400,32 +400,20 @@
400 preloadIframes(); 400 preloadIframes();
401 } 401 }
402 402
403 - // 向所有运行中的应用发送搜索请求(通过新窗口方式避免刷新现有iframe 403 + // 向所有运行中的应用发送搜索请求(通过刷新iframe传递参数
404 let totalRunning = 0; 404 let totalRunning = 0;
405 const ports = { insight: 8501, media: 8502, query: 8503 }; 405 const ports = { insight: 8501, media: 8502, query: 8503 };
406 406
407 Object.keys(appStatus).forEach(app => { 407 Object.keys(appStatus).forEach(app => {
408 - if (appStatus[app] === 'running') { 408 + if (appStatus[app] === 'running' && preloadedIframes[app]) {
409 totalRunning++; 409 totalRunning++;
410 410
411 - // 为每个应用创建一个临时的搜索iframe,避免干扰主iframe  
412 - const searchIframe = document.createElement('iframe');  
413 - searchIframe.style.display = 'none';  
414 - searchIframe.style.position = 'absolute';  
415 - searchIframe.style.top = '-9999px';  
416 - 411 + // 构建搜索URL
417 const searchUrl = `http://localhost:${ports[app]}?query=${encodeURIComponent(query)}&auto_search=true`; 412 const searchUrl = `http://localhost:${ports[app]}?query=${encodeURIComponent(query)}&auto_search=true`;
418 console.log(`向 ${app} 发送搜索请求: ${searchUrl}`); 413 console.log(`向 ${app} 发送搜索请求: ${searchUrl}`);
419 414
420 - searchIframe.src = searchUrl;  
421 - document.body.appendChild(searchIframe);  
422 -  
423 - // 几秒后移除临时iframe  
424 - setTimeout(() => {  
425 - if (searchIframe.parentNode) {  
426 - searchIframe.parentNode.removeChild(searchIframe);  
427 - }  
428 - }, 5000); 415 + // 直接更新主iframe的src来传递搜索参数
  416 + preloadedIframes[app].src = searchUrl;
429 } 417 }
430 }); 418 });
431 419
@@ -436,7 +424,7 @@ @@ -436,7 +424,7 @@
436 } else { 424 } else {
437 button.disabled = false; 425 button.disabled = false;
438 button.innerHTML = '搜索'; 426 button.innerHTML = '搜索';
439 - showMessage(`已向 ${totalRunning} 个应用发送搜索请求`, 'success'); 427 + showMessage(`搜索请求已发送到 ${totalRunning} 个应用,页面将刷新以开始研究`, 'success');
440 } 428 }
441 } 429 }
442 430