diff --git a/app/client/api.ts b/app/client/api.ts index c74c883db..f38c20330 100644 --- a/app/client/api.ts +++ b/app/client/api.ts @@ -37,14 +37,14 @@ export interface MultimodalContent { file_url?: { url: string; name: string; - tokenCount?: string; + tokenCount?: number; }; } export interface UploadFile { name: string; url: string; - tokenCount?: string; + tokenCount?: number; } export interface RequestMessage { diff --git a/app/components/chat.module.scss b/app/components/chat.module.scss index 672c7bffd..9399ece2a 100644 --- a/app/components/chat.module.scss +++ b/app/components/chat.module.scss @@ -71,37 +71,32 @@ border-radius: 5px; margin-right: 10px; - .attach-file-name-full { - max-width:calc(62vw); - display:flex; + %attach-file-name-common { + display:flex; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; + } + .attach-file-name-full { + @extend %attach-file-name-common; + max-width:calc(62vw); + } .attach-file-name-half { + @extend %attach-file-name-common; max-width:calc(45vw); - display:flex; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; } .attach-file-name-less { + @extend %attach-file-name-common; max-width:calc(28vw); - display:flex; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; } .attach-file-name-min { + @extend %attach-file-name-common; max-width:calc(12vw); - display:flex; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } + } .attach-file-icon { min-width: 16px; max-width: 16px; diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 9975e33df..b128f1e7a 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -80,6 +80,7 @@ import { import type { UploadFile } from "../client/api"; import { uploadImage as uploadImageRemote } from "@/app/utils/chat"; +import { uploadImage as uploadFileRemote } from "@/app/utils/chat"; import dynamic from "next/dynamic"; @@ -1193,7 +1194,9 @@ function _Chat() { setIsLoading(true); const textContent = getMessageTextContent(userMessage); const images = getMessageImages(userMessage); - chatStore.onUserInput(textContent, images).then(() => setIsLoading(false)); + chatStore + .onUserInput(textContent, images, attachFiles) + .then(() => setIsLoading(false)); inputRef.current?.focus(); }; @@ -1488,20 +1491,20 @@ function _Chat() { fileInput.multiple = true; fileInput.onchange = (event: any) => { setUploading(true); - const files = event.target.files; + const inputFiles = event.target.files; const imagesData: UploadFile[] = []; (async () => { - for (let i = 0; i < files.length; i++) { - const file = files[i]; + for (let i = 0; i < inputFiles.length; i++) { + const file = inputFiles[i]; try { - const dataUrl = await uploadImageRemote(file); + const dataUrl = await uploadFileRemote(file); const fileData: UploadFile = { name: file.name, url: dataUrl }; - const tokenCount = await countTokens(fileData); + const tokenCount: number = await countTokens(fileData); fileData.tokenCount = tokenCount; imagesData.push(fileData); if ( imagesData.length === 3 || - imagesData.length === files.length + imagesData.length === inputFiles.length ) { setUploading(false); res(imagesData); @@ -1945,7 +1948,7 @@ function _Chat() { {getMessageFiles(message).length > 0 && (