Skip to content

Commit

Permalink
feat: allow send image only
Browse files Browse the repository at this point in the history
  • Loading branch information
Dogtiti committed Oct 8, 2024
1 parent 2bac174 commit 7d55a6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
7 changes: 5 additions & 2 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ import { getClientConfig } from "../config/client";
import { useAllModels } from "../utils/hooks";
import { MultimodalContent } from "../client/api";

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

import { isEmpty } from "lodash-es";

const localStorage = safeLocalStorage();

const ttsPlayer = createTTSPlayer();

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

const doSubmit = (userInput: string) => {
if (userInput.trim() === "") return;
if (userInput.trim() === "" && isEmpty(attachImages)) return;
const matchCommand = chatCommands.match(userInput);
if (matchCommand.matched) {
setUserInput("");
Expand Down
22 changes: 8 additions & 14 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,22 +337,16 @@ export const useChatStore = createPersistStore(

if (attachImages && attachImages.length > 0) {
mContent = [
{
type: "text",
text: userContent,
},
...(userContent
? [{ type: "text" as const, text: userContent }]
: []),
...attachImages.map((url) => ({
type: "image_url" as const,
image_url: { url },
})),
];
mContent = mContent.concat(
attachImages.map((url) => {
return {
type: "image_url",
image_url: {
url: url,
},
};
}),
);
}

let userMessage: ChatMessage = createMessage({
role: "user",
content: mContent,
Expand Down

0 comments on commit 7d55a6d

Please sign in to comment.