From a4a74904a607d0915357f3f6378baea9499780e3 Mon Sep 17 00:00:00 2001 From: Zhang Minghan Date: Thu, 9 Nov 2023 18:38:53 +0800 Subject: [PATCH] update prompt size feature --- app/src/components/FileProvider.tsx | 8 ++++---- app/src/conf.ts | 4 ++-- app/src/conversation/file.ts | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/components/FileProvider.tsx b/app/src/components/FileProvider.tsx index f109198..7127700 100644 --- a/app/src/components/FileProvider.tsx +++ b/app/src/components/FileProvider.tsx @@ -42,7 +42,7 @@ function FileProvider({ value, onChange }: FileProviderProps) { function addFile(file: FileObject) { console.debug( - `[file] new file was added (filename: ${file.name}, size: ${file.content.length})`, + `[file] new file was added (filename: ${file.name}, size: ${file.size}, prompt: ${file.content.length})`, ); if ( file.content.length > MaxPromptSize && @@ -99,7 +99,7 @@ function FileList({ value, removeFile }: FileListProps) { const [full, setFull] = useState(false); const file = useMemo(() => value[0], [value]); const size = useMemo( - () => value.reduce((acc, cur) => acc + cur.content.length, 0), + () => value.reduce((acc, cur) => acc + (cur.size || cur.content.length), 0), [value], ); @@ -130,7 +130,7 @@ function FileList({ value, removeFile }: FileListProps) {
{file.name}
- {(file.content.length / 1024).toFixed(2)}KB + {((file.size || file.content.length) / 1024).toFixed(2)}KB