You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Publish a reflect request to the research service
509
+
//publish a reflect request to the research service
521
510
awaitresearchTopicPub.publish({
522
511
summaries: [
523
-
// Reset to the newly compacted summary
512
+
// Keep all previous summaries and add the new one
513
+
...message.summaries,
524
514
summary,
525
515
],
526
516
remainingIterations: message.remainingIterations,
@@ -542,19 +532,29 @@ async function handleReflect(message: ReflectTopicMessage) {
542
532
console.log(
543
533
`[Research] No iterations remaining. Writing final summary to bucket.`,
544
534
)
545
-
// Combine all summaries with clear topic separation
546
-
const finalSummary =message.summaries
547
-
.map(
548
-
(summary, index) =>
549
-
`## Research Topic: ${message.topics[index]}\n${summary}`,
550
-
)
551
-
.join('\n\n')
535
+
// Create a more comprehensive final summary with proper structure
536
+
const finalSummary =`# Research Summary: ${message.topics[0]}
537
+
538
+
## Introduction
539
+
This document contains research findings on the topic "${message.topics[0]}". The research was conducted through multiple iterations of querying, analyzing, and synthesizing information.
540
+
541
+
## Research Findings
542
+
${message.summaries
543
+
.map(
544
+
(summary, index) =>
545
+
`### Research Topic: ${message.topics[index]}\n\n${summary}`,
546
+
)
547
+
.join('\n\n')}
548
+
549
+
## Conclusion
550
+
This research provides a comprehensive overview of "${message.topics[0]}" and related topics. The findings are based on multiple sources and have been synthesized to provide a coherent understanding of the subject matter.
@@ -587,19 +587,48 @@ async function handleReflect(message: ReflectTopicMessage) {
587
587
console.log(
588
588
`[Research] No knowledge gaps found. Writing final summary to bucket: ${message.topics[message.topics.length-1]}`,
589
589
)
590
-
// Combine all summaries with clear topic separation
591
-
const finalSummary =message.summaries
592
-
.map(
593
-
(summary, index) =>
594
-
`## Research Topic: ${message.topics[index]}\n${summary}`,
595
-
)
596
-
.join('\n\n')
590
+
// Create a more comprehensive final summary with proper structure
591
+
const finalSummary =`# Research Summary: ${message.topics[0]}
592
+
593
+
## Introduction
594
+
This document contains research findings on the topic "${message.topics[0]}". The research was conducted through multiple iterations of querying, analyzing, and synthesizing information.
595
+
596
+
## Research Findings
597
+
${message.summaries
598
+
.map(
599
+
(summary, index) =>
600
+
`### Research Topic: ${message.topics[index]}\n\n${summary}`,
601
+
)
602
+
.join('\n\n')}
603
+
604
+
## Conclusion
605
+
This research provides a comprehensive overview of "${message.topics[0]}" and related topics. The findings are based on multiple sources and have been synthesized to provide a coherent understanding of the subject matter.
606
+
`
597
607
598
608
console.log(`[Research] Final summary length: ${finalSummary.length}`)
0 commit comments