retry button

This commit is contained in:
2023-03-22 14:42:27 +08:00
parent 2ed7f9d05a
commit 371adfb1d4

View File

@@ -13,6 +13,7 @@ export default function ChatBOX(props: {
const [inputMsg, setInputMsg] = useState("");
const [showGenerating, setShowGenerating] = useState(false);
const [generatingMessage, setGeneratingMessage] = useState("");
const [showRetry, setShowRetry] = useState(false);
const client = new ChatGPT(chatStore.apiKey);
@@ -113,6 +114,7 @@ export default function ChatBOX(props: {
console.log("postBeginIndex", chatStore.postBeginIndex);
setChatStore({ ...chatStore });
} catch (error) {
setShowRetry(true);
alert(error);
} finally {
setShowGenerating(false);
@@ -235,6 +237,19 @@ export default function ChatBOX(props: {
...
</p>
)}
{showRetry && (
<p className="text-right p-2 my-2 dark:text-white">
<button
className="p-1 rounded bg-rose-500"
onClick={async () => {
setShowRetry(false);
await complete();
}}
>
Retry
</button>
</p>
)}
</div>
<div className="flex justify-between">
<textarea