From de5db4f805b40fa3944e746917babaa1c7dec1d6 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Sat, 12 Oct 2024 14:56:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E9=80=89=E6=8B=A9=E6=96=87=E6=9C=AC=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/services/FileManager.ts | 2 +- src/renderer/src/i18n/en-us.json | 2 +- src/renderer/src/i18n/zh-cn.json | 2 +- src/renderer/src/i18n/zh-tw.json | 2 +- src/renderer/src/pages/home/Inputbar/AttachmentButton.tsx | 4 +++- src/renderer/src/services/tokens.ts | 4 +--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/services/FileManager.ts b/src/main/services/FileManager.ts index 3ebc477b..45cc73e7 100644 --- a/src/main/services/FileManager.ts +++ b/src/main/services/FileManager.ts @@ -174,7 +174,7 @@ class FileManager { } public readFile = async (_: Electron.IpcMainInvokeEvent, id: string): Promise => { - const filePath = id.includes('/') ? id : path.join(this.storageDir, id) + const filePath = path.join(this.storageDir, id) if (documentExts.includes(path.extname(filePath))) { return await officeParser.parseOfficeAsync(filePath) diff --git a/src/renderer/src/i18n/en-us.json b/src/renderer/src/i18n/en-us.json index b40262ed..53d0c3b0 100644 --- a/src/renderer/src/i18n/en-us.json +++ b/src/renderer/src/i18n/en-us.json @@ -90,7 +90,7 @@ "input.send": "Send", "input.pause": "Pause", "input.settings": "Settings", - "input.upload": "Upload image or text file", + "input.upload": "Upload image or document file", "input.context_count.tip": "Context Count", "input.estimated_tokens.tip": "Estimated tokens", "settings.temperature": "Temperature", diff --git a/src/renderer/src/i18n/zh-cn.json b/src/renderer/src/i18n/zh-cn.json index a3398f00..499eee3d 100644 --- a/src/renderer/src/i18n/zh-cn.json +++ b/src/renderer/src/i18n/zh-cn.json @@ -90,7 +90,7 @@ "input.send": "发送", "input.pause": "暂停", "input.settings": "设置", - "input.upload": "上传图片或纯文本文件", + "input.upload": "上传图片或文档", "input.context_count.tip": "上下文数", "input.estimated_tokens.tip": "预估 token 数", "settings.temperature": "模型温度", diff --git a/src/renderer/src/i18n/zh-tw.json b/src/renderer/src/i18n/zh-tw.json index 10040c35..b2a01cad 100644 --- a/src/renderer/src/i18n/zh-tw.json +++ b/src/renderer/src/i18n/zh-tw.json @@ -90,7 +90,7 @@ "input.send": "發送", "input.pause": "暫停", "input.settings": "設定", - "input.upload": "上傳圖片或文字檔", + "input.upload": "上傳圖片或文檔", "input.context_count.tip": "上下文數量", "input.estimated_tokens.tip": "預估 Token 數", "settings.temperature": "溫度", diff --git a/src/renderer/src/pages/home/Inputbar/AttachmentButton.tsx b/src/renderer/src/pages/home/Inputbar/AttachmentButton.tsx index 3986bd89..6d51565e 100644 --- a/src/renderer/src/pages/home/Inputbar/AttachmentButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/AttachmentButton.tsx @@ -15,7 +15,9 @@ interface Props { const AttachmentButton: FC = ({ model, files, setFiles, ToolbarButton }) => { const { t } = useTranslation() - const extensions = isVisionModel(model) ? [...imageExts, ...textExts, ...documentExts] : [...textExts] + const extensions = isVisionModel(model) + ? [...imageExts, ...documentExts, ...textExts] + : [...documentExts, ...textExts] const onSelectFile = async () => { if (files.length > 0) { diff --git a/src/renderer/src/services/tokens.ts b/src/renderer/src/services/tokens.ts index d5e0d4c1..816123f8 100644 --- a/src/renderer/src/services/tokens.ts +++ b/src/renderer/src/services/tokens.ts @@ -17,10 +17,8 @@ async function getFileContent(file: FileType) { return '' } - const fileId = file.id + file.ext - if (file.type === FileTypes.TEXT) { - return await window.api.file.read(fileId) + return await window.api.file.read(file.id + file.ext) } return ''