feat: Ability to send image without text

This commit is contained in:
n4ze3m 2024-11-09 17:13:23 +05:30
parent fd654cafdb
commit 977723f71f
2 changed files with 10 additions and 6 deletions

View File

@ -159,7 +159,7 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
e.preventDefault()
stopListening()
form.onSubmit(async (value) => {
if (value.message.trim().length === 0) {
if (value.message.trim().length === 0 && value.image.length === 0) {
return
}
if (!selectedModel || selectedModel.length === 0) {
@ -228,6 +228,9 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
return
}
}
if (value.message.trim().length === 0 && value.image.length === 0) {
return
}
form.reset()
textAreaFocus()
await sendMessage({
@ -261,7 +264,6 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
onKeyDown={(e) => handleKeyDown(e)}
ref={textareaRef}
className="px-2 py-2 w-full resize-none bg-transparent focus-within:outline-none focus:ring-0 focus-visible:ring-0 ring-0 dark:ring-0 border-0 dark:text-gray-100"
required
onPaste={handlePaste}
rows={1}
style={{ minHeight: "40px" }}
@ -409,4 +411,4 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
</div>
</div>
)
}
}

View File

@ -75,10 +75,10 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
) {
e.preventDefault()
form.onSubmit(async (value) => {
await stopListening()
if (value.message.trim().length === 0) {
if (value.message.trim().length === 0 && value.image.length === 0) {
return
}
await stopListening()
if (!selectedModel || selectedModel.length === 0) {
form.setFieldError("message", t("formError.noModel"))
return
@ -237,6 +237,9 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
}
}
await stopListening()
if (value.message.trim().length === 0 && value.image.length === 0) {
return
}
form.reset()
textAreaFocus()
await sendMessage({
@ -260,7 +263,6 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
onKeyDown={(e) => handleKeyDown(e)}
ref={textareaRef}
className="px-2 py-2 w-full resize-none bg-transparent focus-within:outline-none focus:ring-0 focus-visible:ring-0 ring-0 dark:ring-0 border-0 dark:text-gray-100"
required
onPaste={handlePaste}
rows={1}
style={{ minHeight: "60px" }}