fix: Do not send empty messages.

This commit is contained in:
Ethan Liu 2023-06-21 12:24:50 +08:00
parent cfd367baf9
commit 62de89520a

View file

@ -15,7 +15,7 @@ import { IconArrowElbow, IconPlus } from '@/components/ui/icons'
export interface PromptProps export interface PromptProps
extends Pick<UseChatHelpers, 'input' | 'setInput'> { extends Pick<UseChatHelpers, 'input' | 'setInput'> {
onSubmit: (value: string) => void onSubmit: (value: string) => Promise<void>
isLoading: boolean isLoading: boolean
} }
@ -38,7 +38,7 @@ export function PromptForm({
<form <form
onSubmit={async e => { onSubmit={async e => {
e.preventDefault() e.preventDefault()
if (input === '') { if (!input?.trim()) {
return return
} }
setInput('') setInput('')