mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-19 16:20:05 +02:00
Make docs show up immediately rather than wait until first answer token
This commit is contained in:
parent
a73ea23e2c
commit
67fd244e66
@ -42,7 +42,7 @@ export const SearchResultsDisplay: React.FC<SearchResultsDisplayProps> = ({
|
|||||||
|
|
||||||
const { answer, quotes, documents, error } = searchResponse;
|
const { answer, quotes, documents, error } = searchResponse;
|
||||||
|
|
||||||
if (isFetching && !answer) {
|
if (isFetching && !answer && !documents) {
|
||||||
return (
|
return (
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<div className="mx-auto">
|
<div className="mx-auto">
|
||||||
@ -71,17 +71,36 @@ export const SearchResultsDisplay: React.FC<SearchResultsDisplayProps> = ({
|
|||||||
searchResponse.suggestedFlowType === FlowType.QUESTION_ANSWER ||
|
searchResponse.suggestedFlowType === FlowType.QUESTION_ANSWER ||
|
||||||
defaultOverrides.forceDisplayQA;
|
defaultOverrides.forceDisplayQA;
|
||||||
|
|
||||||
|
let answerDisplay = <LoadingAnimation text="" size="text-sm" />;
|
||||||
|
if (error) {
|
||||||
|
answerDisplay = (
|
||||||
|
<div className="flex">
|
||||||
|
<InfoIcon
|
||||||
|
size={20}
|
||||||
|
className="text-red-500 my-auto flex flex-shrink-0"
|
||||||
|
/>
|
||||||
|
<div className="text-red-500 text-sm my-auto ml-1">{error}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else if (answer) {
|
||||||
|
answerDisplay = <p className="mb-4">{answer}</p>;
|
||||||
|
} else if (!isFetching) {
|
||||||
|
answerDisplay = (
|
||||||
|
<div className="text-sm my-auto text-gray-300">Information not found</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{answer && shouldDisplayQA && (
|
{shouldDisplayQA && (
|
||||||
<div className="min-h-[14rem]">
|
<div className="min-h-[14rem]">
|
||||||
<div className="p-4 border-2 rounded-md border-gray-700">
|
<div className="p-4 border-2 rounded-md border-gray-700">
|
||||||
<div className="flex mb-1">
|
<div className="flex mb-1">
|
||||||
<h2 className="text font-bold my-auto">AI Answer</h2>
|
<h2 className="text font-bold my-auto">AI Answer</h2>
|
||||||
</div>
|
</div>
|
||||||
<p className="mb-4">{answer}</p>
|
{answerDisplay}
|
||||||
|
|
||||||
{quotes !== null && (
|
{quotes !== null && answer && (
|
||||||
<>
|
<>
|
||||||
<h2 className="text-sm font-bold mb-2">Sources</h2>
|
<h2 className="text-sm font-bold mb-2">Sources</h2>
|
||||||
{isFetching && dedupedQuotes.length === 0 ? (
|
{isFetching && dedupedQuotes.length === 0 ? (
|
||||||
@ -124,20 +143,6 @@ export const SearchResultsDisplay: React.FC<SearchResultsDisplayProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(answer === null || answer === undefined) &&
|
|
||||||
!isFetching &&
|
|
||||||
shouldDisplayQA && (
|
|
||||||
<div className="flex">
|
|
||||||
<InfoIcon
|
|
||||||
size={20}
|
|
||||||
className="text-red-500 my-auto flex flex-shrink-0"
|
|
||||||
/>
|
|
||||||
<div className="text-red-500 text-xs my-auto ml-1">
|
|
||||||
{error ?? "GPT hurt itself in its confusion :("}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{documents && documents.length > 0 && (
|
{documents && documents.length > 0 && (
|
||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<div className="font-bold border-b mb-4 pb-1 border-gray-800">
|
<div className="font-bold border-b mb-4 pb-1 border-gray-800">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user