mirror of
https://github.com/arc53/DocsGPT
synced 2024-11-17 21:26:26 +00:00
chore: retry btn is side-by-side with error mssg
This commit is contained in:
parent
2c100825cc
commit
544c46cd44
@ -19,6 +19,7 @@ import { FEEDBACK, Query } from './conversationModels';
|
|||||||
import { sendFeedback } from './conversationApi';
|
import { sendFeedback } from './conversationApi';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import ArrowDown from './../assets/arrow-down.svg';
|
import ArrowDown from './../assets/arrow-down.svg';
|
||||||
|
import RetryIcon from '../components/RetryIcon';
|
||||||
export default function Conversation() {
|
export default function Conversation() {
|
||||||
const queries = useSelector(selectQueries);
|
const queries = useSelector(selectQueries);
|
||||||
const status = useSelector(selectStatus);
|
const status = useSelector(selectStatus);
|
||||||
@ -151,13 +152,32 @@ export default function Conversation() {
|
|||||||
></ConversationBubble>
|
></ConversationBubble>
|
||||||
);
|
);
|
||||||
} else if (query.error) {
|
} else if (query.error) {
|
||||||
|
const retryBtn = (
|
||||||
|
<button
|
||||||
|
className="flex items-center justify-center gap-3 self-center rounded-full border border-silver py-3 px-5 text-lg text-gray-500 transition-colors delay-100 hover:border-gray-500 disabled:cursor-not-allowed dark:text-bright-gray"
|
||||||
|
disabled={status === 'loading'}
|
||||||
|
onClick={() => {
|
||||||
|
handleQuestion({
|
||||||
|
question: queries[queries.length - 1].prompt,
|
||||||
|
isRetry: true,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<RetryIcon
|
||||||
|
fill={isDarkTheme ? 'rgb(236 236 241)' : 'rgb(107 114 120)'}
|
||||||
|
stroke={isDarkTheme ? 'rgb(236 236 241)' : 'rgb(107 114 120)'}
|
||||||
|
/>
|
||||||
|
Retry
|
||||||
|
</button>
|
||||||
|
);
|
||||||
responseView = (
|
responseView = (
|
||||||
<ConversationBubble
|
<ConversationBubble
|
||||||
ref={endMessageRef}
|
ref={endMessageRef}
|
||||||
className={`${index === queries.length - 1 ? 'mb-32' : 'mb-7'}`}
|
className={`${index === queries.length - 1 ? 'mb-32' : 'mb-7'} `}
|
||||||
key={`${index}ERROR`}
|
key={`${index}ERROR`}
|
||||||
message={query.error}
|
message={query.error}
|
||||||
type="ERROR"
|
type="ERROR"
|
||||||
|
retryBtn={retryBtn}
|
||||||
></ConversationBubble>
|
></ConversationBubble>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -213,6 +233,7 @@ export default function Conversation() {
|
|||||||
|
|
||||||
{queries.length === 0 && <Hero handleQuestion={handleQuestion} />}
|
{queries.length === 0 && <Hero handleQuestion={handleQuestion} />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bottom-safe fixed flex w-11/12 flex-col items-end self-center rounded-2xl bg-opacity-0 pb-1 sm:w-6/12">
|
<div className="bottom-safe fixed flex w-11/12 flex-col items-end self-center rounded-2xl bg-opacity-0 pb-1 sm:w-6/12">
|
||||||
<div className="flex h-full w-full items-center rounded-full border border-silver bg-white dark:bg-raisin-black">
|
<div className="flex h-full w-full items-center rounded-full border border-silver bg-white dark:bg-raisin-black">
|
||||||
<div
|
<div
|
||||||
|
@ -23,9 +23,10 @@ const ConversationBubble = forwardRef<
|
|||||||
feedback?: FEEDBACK;
|
feedback?: FEEDBACK;
|
||||||
handleFeedback?: (feedback: FEEDBACK) => void;
|
handleFeedback?: (feedback: FEEDBACK) => void;
|
||||||
sources?: { title: string; text: string; source: string }[];
|
sources?: { title: string; text: string; source: string }[];
|
||||||
|
retryBtn?: React.ReactElement;
|
||||||
}
|
}
|
||||||
>(function ConversationBubble(
|
>(function ConversationBubble(
|
||||||
{ message, type, className, feedback, handleFeedback, sources },
|
{ message, type, className, feedback, handleFeedback, sources, retryBtn },
|
||||||
ref,
|
ref,
|
||||||
) {
|
) {
|
||||||
const [openSource, setOpenSource] = useState<number | null>(null);
|
const [openSource, setOpenSource] = useState<number | null>(null);
|
||||||
@ -69,12 +70,17 @@ const ConversationBubble = forwardRef<
|
|||||||
<div
|
<div
|
||||||
className={`ml-2 mr-5 flex max-w-[90vw] rounded-3xl bg-gray-1000 p-3.5 dark:bg-gun-metal md:max-w-[70vw] lg:max-w-[50vw] ${
|
className={`ml-2 mr-5 flex max-w-[90vw] rounded-3xl bg-gray-1000 p-3.5 dark:bg-gun-metal md:max-w-[70vw] lg:max-w-[50vw] ${
|
||||||
type === 'ERROR'
|
type === 'ERROR'
|
||||||
? 'flex-row items-center rounded-full border border-transparent bg-[#FFE7E7] p-2 py-5 text-sm font-normal text-red-3000 dark:border-red-2000 dark:text-white'
|
? 'relative flex-row items-center rounded-full border border-transparent bg-[#FFE7E7] p-2 py-5 text-sm font-normal text-red-3000 dark:border-red-2000 dark:text-white'
|
||||||
: 'flex-col rounded-3xl'
|
: 'flex-col rounded-3xl'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{type === 'ERROR' && (
|
{type === 'ERROR' && (
|
||||||
|
<>
|
||||||
<img src={Alert} alt="alert" className="mr-2 inline" />
|
<img src={Alert} alt="alert" className="mr-2 inline" />
|
||||||
|
<div className="absolute -right-32 top-1/2 -translate-y-1/2">
|
||||||
|
{retryBtn}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
className="whitespace-pre-wrap break-normal leading-normal"
|
className="whitespace-pre-wrap break-normal leading-normal"
|
||||||
|
Loading…
Reference in New Issue
Block a user