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?
This commit is contained in:
Debanjum 2024-10-26 10:39:45 -07:00
parent 3e97ebf0c7
commit bf96d81943

View file

@ -3,6 +3,7 @@ import logging
from datetime import datetime from datetime import datetime
from typing import Any, Callable, Dict, List, Optional from typing import Any, Callable, Dict, List, Optional
import yaml
from fastapi import Request from fastapi import Request
from khoj.database.adapters import ConversationAdapters, EntryAdapters 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: if compiled_references or online_results or code_results or summarize_files:
results_data = f"**Results**:\n" results_data = f"**Results**:\n"
if compiled_references: 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: 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: 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: 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) # intermediate_result = await extract_relevant_info(this_iteration.query, results_data, agent)
this_iteration.summarizedResult = results_data this_iteration.summarizedResult = results_data