From bf96d8194331b75b760cf7d23cdd4a6f3ea9cdbd Mon Sep 17 00:00:00 2001 From: Debanjum Date: Sat, 26 Oct 2024 10:39:45 -0700 Subject: [PATCH] Format online results as YAML to pass it in more readable form to model Previous passing of online results as json dump in prompts was less readable for humans, and I'm guessing less readable for models (trained on human data) as well? --- src/khoj/routers/research.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/khoj/routers/research.py b/src/khoj/routers/research.py index 8221fd5c..94e19868 100644 --- a/src/khoj/routers/research.py +++ b/src/khoj/routers/research.py @@ -3,6 +3,7 @@ import logging from datetime import datetime from typing import Any, Callable, Dict, List, Optional +import yaml from fastapi import Request from khoj.database.adapters import ConversationAdapters, EntryAdapters @@ -307,13 +308,13 @@ async def execute_information_collection( if compiled_references or online_results or code_results or summarize_files: results_data = f"**Results**:\n" if compiled_references: - results_data += f"**Document References**: {compiled_references}\n" + results_data += f"**Document References**: {yaml.dump(compiled_references, allow_unicode=True, sort_keys=False, default_flow_style=False)}\n" if online_results: - results_data += f"**Online Results**: {online_results}\n" + results_data += f"**Online Results**: {yaml.dump(online_results, allow_unicode=True, sort_keys=False, default_flow_style=False)}\n" if code_results: - results_data += f"**Code Results**: {code_results}\n" + results_data += f"**Code Results**: {yaml.dump(code_results, allow_unicode=True, sort_keys=False, default_flow_style=False)}\n" if summarize_files: - results_data += f"**Summarized Files**: {summarize_files}\n" + results_data += f"**Summarized Files**: {yaml.dump(summarize_files, allow_unicode=True, sort_keys=False, default_flow_style=False)}\n" # intermediate_result = await extract_relevant_info(this_iteration.query, results_data, agent) this_iteration.summarizedResult = results_data