Track research results as iteration list instead of iteration summaries

This commit is contained in:
Debanjum
2025-05-20 15:31:33 -07:00
parent 5d65fa8698
commit df9ab51fd0
2 changed files with 10 additions and 7 deletions

View File

@@ -883,7 +883,7 @@ async def chat(
user_message_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
meta_log = conversation.conversation_log
researched_results = ""
research_results: List[InformationCollectionIteration] = []
online_results: Dict = dict()
code_results: Dict = dict()
operator_results: Dict[str, str] = {}
@@ -963,14 +963,14 @@ async def chat(
compiled_references.extend(research_result.context)
if research_result.operatorContext:
operator_results.update(research_result.operatorContext)
researched_results += research_result.summarizedResult
research_results.append(research_result)
else:
yield research_result
# researched_results = await extract_relevant_info(q, researched_results, agent)
if state.verbose > 1:
logger.debug(f"Researched Results: {researched_results}")
logger.debug(f'Researched Results: {"".join(r.summarizedResult for r in research_results)}')
used_slash_summarize = conversation_commands == [ConversationCommand.Summarize]
file_filters = conversation.file_filters if conversation else []
@@ -1379,13 +1379,13 @@ async def chat(
online_results,
code_results,
operator_results,
research_results,
inferred_queries,
conversation_commands,
user,
request.user.client_app,
location,
user_name,
researched_results,
uploaded_images,
train_of_thought,
attached_file_context,

View File

@@ -94,6 +94,7 @@ from khoj.processor.conversation.openai.gpt import (
)
from khoj.processor.conversation.utils import (
ChatEvent,
InformationCollectionIteration,
ResponseWithThought,
clean_json,
clean_mermaidjs,
@@ -1355,13 +1356,13 @@ async def agenerate_chat_response(
online_results: Dict[str, Dict] = {},
code_results: Dict[str, Dict] = {},
operator_results: Dict[str, str] = {},
research_results: List[InformationCollectionIteration] = [],
inferred_queries: List[str] = [],
conversation_commands: List[ConversationCommand] = [ConversationCommand.Default],
user: KhojUser = None,
client_application: ClientApplication = None,
location_data: LocationData = None,
user_name: Optional[str] = None,
meta_research: str = "",
query_images: Optional[List[str]] = None,
train_of_thought: List[Any] = [],
query_files: str = None,
@@ -1405,8 +1406,10 @@ async def agenerate_chat_response(
query_to_run = q
deepthought = False
if meta_research:
query_to_run = f"<query>{q}</query>\n<collected_research>\n{meta_research}\n</collected_research>"
if research_results:
compiled_research = "".join([r.summarizedResult for r in research_results if r.summarizedResult])
if compiled_research:
query_to_run = f"<query>{q}</query>\n<collected_research>\n{compiled_research}\n</collected_research>"
compiled_references = []
online_results = {}
code_results = {}