Skip to content

Commit 7d55a6d

Browse files
committed
feat: allow send image only
1 parent 2bac174 commit 7d55a6d

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

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
@@ -337,22 +337,16 @@ export const useChatStore = createPersistStore(
337337

338338
if (attachImages && attachImages.length > 0) {
339339
mContent = [
340-
{
341-
type: "text",
342-
text: userContent,
343-
},
340+
...(userContent
341+
? [{ type: "text" as const, text: userContent }]
342+
: []),
343+
...attachImages.map((url) => ({
344+
type: "image_url" as const,
345+
image_url: { url },
346+
})),
344347
];
345-
mContent = mContent.concat(
346-
attachImages.map((url) => {
347-
return {
348-
type: "image_url",
349-
image_url: {
350-
url: url,
351-
},
352-
};
353-
}),
354-
);
355348
}
349+
356350
let userMessage: ChatMessage = createMessage({
357351
role: "user",
358352
content: mContent,

0 commit comments

Comments
 (0)