diff --git a/src/interface/desktop/main.js b/src/interface/desktop/main.js index d4208449..7c7bf4fc 100644 --- a/src/interface/desktop/main.js +++ b/src/interface/desktop/main.js @@ -19,7 +19,7 @@ const textFileTypes = [ 'org', 'md', 'markdown', 'txt', 'html', 'xml', // Other valid text file extensions from https://google.github.io/magika/model/config.json 'appleplist', 'asm', 'asp', 'batch', 'c', 'cs', 'css', 'csv', 'eml', 'go', 'html', 'ini', 'internetshortcut', 'java', 'javascript', 'json', 'latex', 'lisp', 'makefile', 'markdown', 'mht', 'mum', 'pem', 'perl', 'php', 'powershell', 'python', 'rdf', 'rst', 'rtf', 'ruby', 'rust', 'scala', 'shell', 'smali', 'sql', 'svg', 'symlinktext', 'txt', 'vba', 'winregistry', 'xml', 'yaml'] -const binaryFileTypes = ['pdf', 'jpg', 'jpeg', 'png'] +const binaryFileTypes = ['pdf', 'jpg', 'jpeg', 'png', 'webp'] const validFileTypes = textFileTypes.concat(binaryFileTypes); const schema = { @@ -104,6 +104,8 @@ function filenameToMimeType (filename) { case 'jpg': case 'jpeg': return 'image/jpeg'; + case 'webp': + return 'image/webp'; case 'md': case 'markdown': return 'text/markdown'; diff --git a/src/interface/obsidian/src/utils.ts b/src/interface/obsidian/src/utils.ts index 2395c529..3cc83fb8 100644 --- a/src/interface/obsidian/src/utils.ts +++ b/src/interface/obsidian/src/utils.ts @@ -37,6 +37,8 @@ function filenameToMimeType (filename: TFile): string { case 'jpg': case 'jpeg': return 'image/jpeg'; + case 'webp': + return 'image/webp'; case 'md': case 'markdown': return 'text/markdown'; @@ -50,7 +52,7 @@ function filenameToMimeType (filename: TFile): string { export const fileTypeToExtension = { 'pdf': ['pdf'], - 'image': ['png', 'jpg', 'jpeg'], + 'image': ['png', 'jpg', 'jpeg', 'webp'], 'markdown': ['md', 'markdown'], }; export const supportedImageFilesTypes = fileTypeToExtension.image; diff --git a/src/interface/web/app/common/iconUtils.tsx b/src/interface/web/app/common/iconUtils.tsx index c84f0cc4..1a6ca0e1 100644 --- a/src/interface/web/app/common/iconUtils.tsx +++ b/src/interface/web/app/common/iconUtils.tsx @@ -241,6 +241,7 @@ function getIconFromFilename( case "jpg": case "jpeg": case "png": + case "webp": return ; default: return ; diff --git a/src/interface/web/app/components/chatInputArea/chatInputArea.tsx b/src/interface/web/app/components/chatInputArea/chatInputArea.tsx index 2b4975e9..d85d6a54 100644 --- a/src/interface/web/app/components/chatInputArea/chatInputArea.tsx +++ b/src/interface/web/app/components/chatInputArea/chatInputArea.tsx @@ -168,12 +168,12 @@ export default function ChatInputArea(props: ChatInputProps) { function uploadFiles(files: FileList) { if (!props.isLoggedIn) { - setLoginRedirectMessage("Whoa! You need to login to upload files"); + setLoginRedirectMessage("Please login to chat with your files"); setShowLoginPrompt(true); return; } // check for image file - const image_endings = ["jpg", "jpeg", "png"]; + const image_endings = ["jpg", "jpeg", "png", "webp"]; for (let i = 0; i < files.length; i++) { const file = files[i]; const file_extension = file.name.split(".").pop(); diff --git a/src/khoj/processor/content/images/image_to_entries.py b/src/khoj/processor/content/images/image_to_entries.py index 6dcd728c..87b9a009 100644 --- a/src/khoj/processor/content/images/image_to_entries.py +++ b/src/khoj/processor/content/images/image_to_entries.py @@ -64,6 +64,8 @@ class ImageToEntries(TextToEntries): tmp_file = f"tmp_image_file_{timestamp_now}.png" elif image_file.endswith(".jpg") or image_file.endswith(".jpeg"): tmp_file = f"tmp_image_file_{timestamp_now}.jpg" + elif image_file.endswith(".webp"): + tmp_file = f"tmp_image_file_{timestamp_now}.webp" with open(tmp_file, "wb") as f: bytes = image_files[image_file] f.write(bytes) diff --git a/src/khoj/utils/helpers.py b/src/khoj/utils/helpers.py index 7006d7d4..abc65b77 100644 --- a/src/khoj/utils/helpers.py +++ b/src/khoj/utils/helpers.py @@ -127,6 +127,8 @@ def get_file_type(file_type: str, file_content: bytes) -> tuple[str, str]: return "image", encoding elif file_type in ["image/png"]: return "image", encoding + elif file_type in ["image/webp"]: + return "image", encoding elif content_group in ["code", "text"]: return "plaintext", encoding else: