mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Pass user query for chat response when document lookup fails
Recent changes made Khoj try respond even when document lookup fails. This change missed handling downstream effects of a failed document lookup, as the defiltered_query was null and so the text response didn't have the user query to respond to. This code initializes defiltered_query to original user query to handle that. Also response_type wasn't being passed via send_message_to_model_wrapper_sync unlike in the async scenario
This commit is contained in:
parent
a4e6e1d5e8
commit
d55cba8627
2 changed files with 4 additions and 4 deletions
|
@ -10,9 +10,8 @@ from urllib.parse import unquote
|
|||
|
||||
from asgiref.sync import sync_to_async
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||
from fastapi.requests import Request
|
||||
from fastapi.responses import Response, StreamingResponse
|
||||
from starlette.authentication import has_required_scope, requires
|
||||
from starlette.authentication import requires
|
||||
|
||||
from khoj.app.settings import ALLOWED_HOSTS
|
||||
from khoj.database.adapters import (
|
||||
|
@ -837,7 +836,7 @@ async def chat(
|
|||
|
||||
# Gather Context
|
||||
## Extract Document References
|
||||
compiled_references, inferred_queries, defiltered_query = [], [], None
|
||||
compiled_references, inferred_queries, defiltered_query = [], [], q
|
||||
try:
|
||||
async for result in extract_references_and_questions(
|
||||
request,
|
||||
|
@ -960,7 +959,7 @@ async def chat(
|
|||
## Generate Image Output
|
||||
if ConversationCommand.Image in conversation_commands:
|
||||
async for result in text_to_image(
|
||||
q,
|
||||
defiltered_query,
|
||||
user,
|
||||
meta_log,
|
||||
location_data=location,
|
||||
|
|
|
@ -881,6 +881,7 @@ def send_message_to_model_wrapper_sync(
|
|||
messages=truncated_messages,
|
||||
api_key=api_key,
|
||||
model=chat_model,
|
||||
response_type=response_type,
|
||||
)
|
||||
else:
|
||||
raise HTTPException(status_code=500, detail="Invalid conversation config")
|
||||
|
|
Loading…
Reference in a new issue