Skip to content

Commit b016771

Browse files
authored
Merge pull request #5599 from ConnectAI-E/feature/allow-send-image-only
feat: allow send image only
2 parents a84383f + 7d55a6d commit b016771

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

app/components/chat.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ import { getClientConfig } from "../config/client";
115115
import { useAllModels } from "../utils/hooks";
116116
import { MultimodalContent } from "../client/api";
117117

118-
const localStorage = safeLocalStorage();
119118
import { ClientApi } from "../client/api";
120119
import { createTTSPlayer } from "../utils/audio";
121120
import { MsEdgeTTS, OUTPUT_FORMAT } from "../utils/ms_edge_tts";
122121

122+
import { isEmpty } from "lodash-es";
123+
124+
const localStorage = safeLocalStorage();
125+
123126
const ttsPlayer = createTTSPlayer();
124127

125128
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
@@ -1015,7 +1018,7 @@ function _Chat() {
10151018
};
10161019

10171020
const doSubmit = (userInput: string) => {
1018-
if (userInput.trim() === "") return;
1021+
if (userInput.trim() === "" && isEmpty(attachImages)) return;
10191022
const matchCommand = chatCommands.match(userInput);
10201023
if (matchCommand.matched) {
10211024
setUserInput("");

app/store/chat.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -372,22 +372,16 @@ export const useChatStore = createPersistStore(
372372

373373
if (attachImages && attachImages.length > 0) {
374374
mContent = [
375-
{
376-
type: "text",
377-
text: userContent,
378-
},
375+
...(userContent
376+
? [{ type: "text" as const, text: userContent }]
377+
: []),
378+
...attachImages.map((url) => ({
379+
type: "image_url" as const,
380+
image_url: { url },
381+
})),
379382
];
380-
mContent = mContent.concat(
381-
attachImages.map((url) => {
382-
return {
383-
type: "image_url",
384-
image_url: {
385-
url: url,
386-
},
387-
};
388-
}),
389-
);
390383
}
384+
391385
let userMessage: ChatMessage = createMessage({
392386
role: "user",
393387
content: mContent,

0 commit comments

Comments
 (0)