From c1fd1d349041b9fd746d335f057ac5da983904f6 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 28 Nov 2024 23:26:09 -0800 Subject: [PATCH] refac: auto completion --- src/lib/components/chat/MessageInput.svelte | 1 + .../components/common/RichTextInput.svelte | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 16e3cdb91..6ebb29428 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -591,6 +591,7 @@ )} placeholder={placeholder ? placeholder : $i18n.t('Send a Message')} largeTextAsFile={$settings?.largeTextAsFile ?? false} + autocomplete={true} bind:value={prompt} on:keydown={async (e) => { e = e.detail.event; diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index bf4a6238a..e2ca453ac 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -151,15 +151,19 @@ Highlight, Typography, Placeholder.configure({ placeholder }), - AIAutocompletion.configure({ - generateCompletion: async (text) => { - if (text.trim().length === 0) { - return null; - } + ...(autocomplete + ? [ + AIAutocompletion.configure({ + generateCompletion: async (text) => { + if (text.trim().length === 0) { + return null; + } - return 'AI-generated suggestion'; - } - }) + return 'AI-generated suggestion'; + } + }) + ] + : []) ], content: content, autofocus: true,