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 ''