diff --git a/README.md b/README.md index f35d66783..4c9aa6b2c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ Also check our sibling project, [OllamaHub](https://ollamahub.com/), where you c - ✒️🔢 **Full Markdown and LaTeX Support**: Elevate your LLM experience with comprehensive Markdown and LaTeX capabilities for enriched interaction. +- 📚 **RAG Integration (Beta)**: Experience first-class retrieval augmented generation support, enabling chat with your documents. + - 📜 **Prompt Preset Support**: Instantly access preset prompts using the '/' command in the chat input. Load predefined conversation starters effortlessly and expedite your interactions. Effortlessly import prompts through [OllamaHub](https://ollamahub.com/) integration. - 👍👎 **RLHF Annotation**: Empower your messages by rating them with thumbs up and thumbs down, facilitating the creation of datasets for Reinforcement Learning from Human Feedback (RLHF). Utilize your messages to train or fine-tune models, all while ensuring the confidentiality of locally saved data. @@ -243,7 +245,6 @@ See [TROUBLESHOOTING.md](/TROUBLESHOOTING.md) for information on how to troubles Here are some exciting tasks on our roadmap: -- 📚 **RAG Integration**: Experience first-class retrieval augmented generation support, enabling chat with your documents. - 🌐 **Web Browsing Capability**: Experience the convenience of seamlessly integrating web content directly into your chat. Easily browse and share information without leaving the conversation. - 🔄 **Function Calling**: Empower your interactions by running code directly within the chat. Execute functions and commands effortlessly, enhancing the functionality of your conversations. - ⚙️ **Custom Python Backend Actions**: Empower your Ollama Web UI by creating or downloading custom Python backend actions. Unleash the full potential of your web interface with tailored actions that suit your specific needs, enhancing functionality and versatility. diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 4cce1fcbd..13078d64f 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -116,8 +116,10 @@ ]; }; - if (e.dataTransfer?.files && e.dataTransfer?.files.length > 0) { - const file = e.dataTransfer?.files[0]; + const inputFiles = e.dataTransfer?.files; + + if (inputFiles && inputFiles.length > 0) { + const file = inputFiles[0]; if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) { reader.readAsDataURL(file); } else if (['application/pdf', 'text/plain'].includes(file['type'])) { @@ -221,7 +223,7 @@ bind:files={inputFiles} type="file" hidden - on:change={() => { + on:change={async () => { let reader = new FileReader(); reader.onload = (event) => { files = [ @@ -235,15 +237,32 @@ filesInputElement.value = ''; }; - if ( - inputFiles && - inputFiles.length > 0 && - ['image/gif', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type']) - ) { - reader.readAsDataURL(inputFiles[0]); + if (inputFiles && inputFiles.length > 0) { + const file = inputFiles[0]; + if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) { + reader.readAsDataURL(file); + } else if (['application/pdf', 'text/plain'].includes(file['type'])) { + console.log(file); + const hash = await calculateSHA256(file); + // const res = uploadDocToVectorDB(localStorage.token,hash,file); + + if (true) { + files = [ + ...files, + { + type: 'doc', + name: file.name, + collection_name: hash + } + ]; + filesInputElement.value = ''; + } + } else { + toast.error(`Unsupported File Type '${file['type']}'.`); + inputFiles = null; + } } else { - toast.error(`Unsupported File Type '${inputFiles[0]['type']}'.`); - inputFiles = null; + toast.error(`File not found.`); } }} />