From ef761f1a43ba69a1bb05d7325fb432169e1f3272 Mon Sep 17 00:00:00 2001 From: Utkarsh-Patel-13 Date: Sat, 19 Jul 2025 21:08:19 -0700 Subject: [PATCH] Updated section streaming for report sections. --- surfsense_backend/app/agents/researcher/nodes.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/surfsense_backend/app/agents/researcher/nodes.py b/surfsense_backend/app/agents/researcher/nodes.py index 49c28b7c6..cbcd44f83 100644 --- a/surfsense_backend/app/agents/researcher/nodes.py +++ b/surfsense_backend/app/agents/researcher/nodes.py @@ -1065,6 +1065,13 @@ async def process_sections(state: State, config: RunnableConfig, writer: StreamW # Skip adding the section header since the content already contains the title final_report.append(content) final_report.append("\n") + + # Stream each section with its title + writer( + { + "yield_value": state.streaming_service.format_text_chunk(f"# {section.section_title}\n\n{content}") + } + ) # Join all sections with newlines @@ -1219,13 +1226,6 @@ async def process_section_with_documents( complete_answer.extend(content_lines) complete_answer.append("") # Empty line after content - # Update answer in UI in real-time - state.streaming_service.only_update_answer(complete_answer) - writer( - { - "yield_value": state.streaming_service._format_annotations() - } - ) # Set default if no content was received if not complete_content: