Improve ux (#558)

* clear content once message sent

* do not retry when tts failed
This commit is contained in:
an-lee
2024-04-22 16:51:20 +08:00
committed by GitHub
parent 654630a51d
commit 5ba486792a
2 changed files with 8 additions and 4 deletions

View File

@@ -73,7 +73,8 @@ export const useConversation = () => {
maxRetries: 2,
});
} else if (conversation.engine === "googleGenerativeAi") {
if (!googleGenerativeAi) throw new Error("Google Generative AI API key is required");
if (!googleGenerativeAi)
throw new Error("Google Generative AI API key is required");
return new ChatGoogleGenerativeAI({
apiKey: googleGenerativeAi.key,
@@ -157,7 +158,7 @@ export const useConversation = () => {
const llm = pickLlm(conversation);
const chain = new ConversationChain({
llm,
llm: llm as any,
memory,
prompt,
verbose: true,
@@ -240,12 +241,14 @@ export const useConversation = () => {
apiKey: user.accessToken,
baseURL: `${apiUrl}/api/ai`,
dangerouslyAllowBrowser: true,
maxRetries: 1,
});
} else if (openai) {
client = new OpenAI({
apiKey: openai.key,
baseURL: baseUrl || openai.baseUrl,
dangerouslyAllowBrowser: true,
maxRetries: 1,
});
} else {
throw new Error("OpenAI API key is required");

View File

@@ -129,9 +129,9 @@ export default () => {
})
.finally(() => {
setSubmitting(false);
setContent("");
clearTimeout(timeout);
});
setContent("");
};
const onMessagesUpdate = (event: CustomEvent) => {
@@ -314,7 +314,6 @@ export default () => {
<div className="focus-within:bg-background pr-4 py-2 flex items-end space-x-4 rounded-lg shadow-lg border scrollbar">
<Textarea
ref={inputRef}
disabled={submitting}
value={content}
onChange={(e) => setContent(e.target.value)}
placeholder={t("pressEnterToSend")}
@@ -328,6 +327,8 @@ export default () => {
disabled={submitting || !content}
data-testid="conversation-page-submit"
onClick={() => handleSubmit(content)}
data-tooltip-id="global-tooltip"
data-tooltip-content={t("send")}
className="h-10"
>
<SendIcon className="w-5 h-5" />