From 6ad85e22756f1830e68b80bc235ae86ba3198b28 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 9 Oct 2024 21:19:04 -0700 Subject: [PATCH] Fix to continue showing retrieved documents in train of thought --- src/khoj/routers/research.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/khoj/routers/research.py b/src/khoj/routers/research.py index 5960c88c..fd52142b 100644 --- a/src/khoj/routers/research.py +++ b/src/khoj/routers/research.py @@ -21,6 +21,7 @@ from khoj.routers.helpers import ( from khoj.utils.helpers import ( ConversationCommand, function_calling_description_for_llm, + is_none_or_empty, timer, ) from khoj.utils.rawconfig import LocationData @@ -189,6 +190,17 @@ async def execute_information_collection( defiltered_query = result[2] this_iteration.context = compiled_references + if not is_none_or_empty(compiled_references): + try: + headings = "\n- " + "\n- ".join(set([c.get("compiled", c).split("\n")[0] for c in compiled_references])) + # Strip only leading # from headings + headings = headings.replace("#", "") + async for result in send_status_func(f"**Found Relevant Notes**: {headings}"): + yield result + except Exception as e: + # TODO Get correct type for compiled across research notes extraction + logger.error(f"Error extracting references: {e}", exc_info=True) + elif this_iteration.data_source == ConversationCommand.Online: async for result in search_online( this_iteration.query,