mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-10-11 13:46:07 +02:00
@@ -1,3 +1,5 @@
|
|||||||
|
import json
|
||||||
|
from collections.abc import Generator
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
@@ -267,10 +269,17 @@ def get_answer_with_quote(
|
|||||||
|
|
||||||
logger.notice(f"Received query for one shot answer with quotes: {query}")
|
logger.notice(f"Received query for one shot answer with quotes: {query}")
|
||||||
|
|
||||||
packets = stream_search_answer(
|
def stream_generator() -> Generator[str, None, None]:
|
||||||
|
try:
|
||||||
|
for packet in stream_search_answer(
|
||||||
query_req=query_request,
|
query_req=query_request,
|
||||||
user=user,
|
user=user,
|
||||||
max_document_tokens=None,
|
max_document_tokens=None,
|
||||||
max_history_tokens=0,
|
max_history_tokens=0,
|
||||||
)
|
):
|
||||||
return StreamingResponse(packets, media_type="application/json")
|
yield json.dumps(packet) if isinstance(packet, dict) else packet
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(f"Error in search answer streaming: {e}")
|
||||||
|
yield json.dumps({"error": str(e)})
|
||||||
|
|
||||||
|
return StreamingResponse(stream_generator(), media_type="application/json")
|
||||||
|
@@ -59,11 +59,6 @@ const SEARCH_DEFAULT_OVERRIDES_START: SearchDefaultOverrides = {
|
|||||||
offset: 0,
|
offset: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const VALID_QUESTION_RESPONSE_DEFAULT: ValidQuestionResponse = {
|
|
||||||
reasoning: null,
|
|
||||||
error: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
interface SearchSectionProps {
|
interface SearchSectionProps {
|
||||||
toggle: () => void;
|
toggle: () => void;
|
||||||
defaultSearchType: SearchType;
|
defaultSearchType: SearchType;
|
||||||
|
Reference in New Issue
Block a user