mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-10 05:39:11 +00:00
Fix notes references and passage of user query in the chat flow
This commit is contained in:
@@ -720,13 +720,11 @@ async def chat(
|
|||||||
if type(research_result) == InformationCollectionIteration:
|
if type(research_result) == InformationCollectionIteration:
|
||||||
if research_result.summarizedResult:
|
if research_result.summarizedResult:
|
||||||
pending_research = False
|
pending_research = False
|
||||||
# if research_result.onlineContext:
|
if research_result.onlineContext:
|
||||||
# researched_results += str(research_result.onlineContext)
|
online_results.update(research_result.onlineContext)
|
||||||
# online_results.update(research_result.onlineContext)
|
|
||||||
|
|
||||||
# if research_result.context:
|
if research_result.context:
|
||||||
# researched_results += str(research_result.context)
|
compiled_references.extend(research_result.context)
|
||||||
# compiled_references.extend(research_result.context)
|
|
||||||
|
|
||||||
researched_results += research_result.summarizedResult
|
researched_results += research_result.summarizedResult
|
||||||
|
|
||||||
@@ -1021,10 +1019,9 @@ async def chat(
|
|||||||
async for result in send_event(ChatEvent.STATUS, f"**Generating a well-informed response**"):
|
async for result in send_event(ChatEvent.STATUS, f"**Generating a well-informed response**"):
|
||||||
yield result
|
yield result
|
||||||
llm_response, chat_metadata = await agenerate_chat_response(
|
llm_response, chat_metadata = await agenerate_chat_response(
|
||||||
defiltered_query,
|
q,
|
||||||
meta_log,
|
meta_log,
|
||||||
conversation,
|
conversation,
|
||||||
researched_results,
|
|
||||||
compiled_references,
|
compiled_references,
|
||||||
online_results,
|
online_results,
|
||||||
inferred_queries,
|
inferred_queries,
|
||||||
@@ -1035,6 +1032,7 @@ async def chat(
|
|||||||
location,
|
location,
|
||||||
user_name,
|
user_name,
|
||||||
uploaded_image_url,
|
uploaded_image_url,
|
||||||
|
researched_results,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Send Response
|
# Send Response
|
||||||
|
|||||||
@@ -947,7 +947,6 @@ def generate_chat_response(
|
|||||||
q: str,
|
q: str,
|
||||||
meta_log: dict,
|
meta_log: dict,
|
||||||
conversation: Conversation,
|
conversation: Conversation,
|
||||||
meta_research: str = "",
|
|
||||||
compiled_references: List[Dict] = [],
|
compiled_references: List[Dict] = [],
|
||||||
online_results: Dict[str, Dict] = {},
|
online_results: Dict[str, Dict] = {},
|
||||||
inferred_queries: List[str] = [],
|
inferred_queries: List[str] = [],
|
||||||
@@ -958,6 +957,7 @@ def generate_chat_response(
|
|||||||
location_data: LocationData = None,
|
location_data: LocationData = None,
|
||||||
user_name: Optional[str] = None,
|
user_name: Optional[str] = None,
|
||||||
uploaded_image_url: Optional[str] = None,
|
uploaded_image_url: Optional[str] = None,
|
||||||
|
meta_research: str = "",
|
||||||
) -> Tuple[Union[ThreadedGenerator, Iterator[str]], Dict[str, str]]:
|
) -> Tuple[Union[ThreadedGenerator, Iterator[str]], Dict[str, str]]:
|
||||||
# Initialize Variables
|
# Initialize Variables
|
||||||
chat_response = None
|
chat_response = None
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class InformationCollectionIteration:
|
|||||||
self,
|
self,
|
||||||
data_source: str,
|
data_source: str,
|
||||||
query: str,
|
query: str,
|
||||||
context: str = None,
|
context: Dict[str, Dict] = None,
|
||||||
onlineContext: dict = None,
|
onlineContext: dict = None,
|
||||||
summarizedResult: str = None,
|
summarizedResult: str = None,
|
||||||
):
|
):
|
||||||
@@ -187,7 +187,7 @@ async def execute_information_collection(
|
|||||||
compiled_references.extend(result[0])
|
compiled_references.extend(result[0])
|
||||||
inferred_queries.extend(result[1])
|
inferred_queries.extend(result[1])
|
||||||
defiltered_query = result[2]
|
defiltered_query = result[2]
|
||||||
this_iteration.context = str(compiled_references)
|
this_iteration.context = compiled_references
|
||||||
|
|
||||||
elif this_iteration.data_source == ConversationCommand.Online:
|
elif this_iteration.data_source == ConversationCommand.Online:
|
||||||
async for result in search_online(
|
async for result in search_online(
|
||||||
|
|||||||
Reference in New Issue
Block a user