From 0ecd5f497dcd89d7bf67bf1f1b07ba1b3d7ed43f Mon Sep 17 00:00:00 2001 From: Debanjum Date: Thu, 3 Jul 2025 16:05:42 -0700 Subject: [PATCH] Show more informative title for semantic search train of thought --- src/khoj/routers/api_chat.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index 6d444b92..c8c23c8f 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -1093,10 +1093,14 @@ async def event_generator( yield result if not is_none_or_empty(compiled_references): - headings = "\n- " + "\n- ".join(set([c.get("compiled", c).split("\n")[0] for c in compiled_references])) + distinct_headings = set([d.get("compiled").split("\n")[0] for d in compiled_references if "compiled" in d]) + distinct_files = set([d["file"] for d in compiled_references]) # Strip only leading # from headings - headings = headings.replace("#", "") - async for result in send_event(ChatEvent.STATUS, f"**Found Relevant Notes**: {headings}"): + headings_str = "\n- " + "\n- ".join(distinct_headings).replace("#", "") + async for result in send_event( + ChatEvent.STATUS, + f"**Found {len(distinct_headings)} Notes Across {len(distinct_files)} Files**: {headings_str}", + ): yield result if conversation_commands == [ConversationCommand.Notes] and not await EntryAdapters.auser_has_entries(user):