mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Track research results as iteration list instead of iteration summaries
This commit is contained in:
@@ -883,7 +883,7 @@ async def chat(
|
|||||||
user_message_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
user_message_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
meta_log = conversation.conversation_log
|
meta_log = conversation.conversation_log
|
||||||
|
|
||||||
researched_results = ""
|
research_results: List[InformationCollectionIteration] = []
|
||||||
online_results: Dict = dict()
|
online_results: Dict = dict()
|
||||||
code_results: Dict = dict()
|
code_results: Dict = dict()
|
||||||
operator_results: Dict[str, str] = {}
|
operator_results: Dict[str, str] = {}
|
||||||
@@ -963,14 +963,14 @@ async def chat(
|
|||||||
compiled_references.extend(research_result.context)
|
compiled_references.extend(research_result.context)
|
||||||
if research_result.operatorContext:
|
if research_result.operatorContext:
|
||||||
operator_results.update(research_result.operatorContext)
|
operator_results.update(research_result.operatorContext)
|
||||||
researched_results += research_result.summarizedResult
|
research_results.append(research_result)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
yield research_result
|
yield research_result
|
||||||
|
|
||||||
# researched_results = await extract_relevant_info(q, researched_results, agent)
|
# researched_results = await extract_relevant_info(q, researched_results, agent)
|
||||||
if state.verbose > 1:
|
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]
|
used_slash_summarize = conversation_commands == [ConversationCommand.Summarize]
|
||||||
file_filters = conversation.file_filters if conversation else []
|
file_filters = conversation.file_filters if conversation else []
|
||||||
@@ -1379,13 +1379,13 @@ async def chat(
|
|||||||
online_results,
|
online_results,
|
||||||
code_results,
|
code_results,
|
||||||
operator_results,
|
operator_results,
|
||||||
|
research_results,
|
||||||
inferred_queries,
|
inferred_queries,
|
||||||
conversation_commands,
|
conversation_commands,
|
||||||
user,
|
user,
|
||||||
request.user.client_app,
|
request.user.client_app,
|
||||||
location,
|
location,
|
||||||
user_name,
|
user_name,
|
||||||
researched_results,
|
|
||||||
uploaded_images,
|
uploaded_images,
|
||||||
train_of_thought,
|
train_of_thought,
|
||||||
attached_file_context,
|
attached_file_context,
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ from khoj.processor.conversation.openai.gpt import (
|
|||||||
)
|
)
|
||||||
from khoj.processor.conversation.utils import (
|
from khoj.processor.conversation.utils import (
|
||||||
ChatEvent,
|
ChatEvent,
|
||||||
|
InformationCollectionIteration,
|
||||||
ResponseWithThought,
|
ResponseWithThought,
|
||||||
clean_json,
|
clean_json,
|
||||||
clean_mermaidjs,
|
clean_mermaidjs,
|
||||||
@@ -1355,13 +1356,13 @@ async def agenerate_chat_response(
|
|||||||
online_results: Dict[str, Dict] = {},
|
online_results: Dict[str, Dict] = {},
|
||||||
code_results: Dict[str, Dict] = {},
|
code_results: Dict[str, Dict] = {},
|
||||||
operator_results: Dict[str, str] = {},
|
operator_results: Dict[str, str] = {},
|
||||||
|
research_results: List[InformationCollectionIteration] = [],
|
||||||
inferred_queries: List[str] = [],
|
inferred_queries: List[str] = [],
|
||||||
conversation_commands: List[ConversationCommand] = [ConversationCommand.Default],
|
conversation_commands: List[ConversationCommand] = [ConversationCommand.Default],
|
||||||
user: KhojUser = None,
|
user: KhojUser = None,
|
||||||
client_application: ClientApplication = None,
|
client_application: ClientApplication = None,
|
||||||
location_data: LocationData = None,
|
location_data: LocationData = None,
|
||||||
user_name: Optional[str] = None,
|
user_name: Optional[str] = None,
|
||||||
meta_research: str = "",
|
|
||||||
query_images: Optional[List[str]] = None,
|
query_images: Optional[List[str]] = None,
|
||||||
train_of_thought: List[Any] = [],
|
train_of_thought: List[Any] = [],
|
||||||
query_files: str = None,
|
query_files: str = None,
|
||||||
@@ -1405,8 +1406,10 @@ async def agenerate_chat_response(
|
|||||||
|
|
||||||
query_to_run = q
|
query_to_run = q
|
||||||
deepthought = False
|
deepthought = False
|
||||||
if meta_research:
|
if research_results:
|
||||||
query_to_run = f"<query>{q}</query>\n<collected_research>\n{meta_research}\n</collected_research>"
|
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 = []
|
compiled_references = []
|
||||||
online_results = {}
|
online_results = {}
|
||||||
code_results = {}
|
code_results = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user