Browse Source

feat: prompt autocompletion user setting

Timothy Jaeryang Baek 3 months ago
parent
commit
d41844c308

+ 2 - 1
src/lib/components/chat/MessageInput.svelte

@@ -694,7 +694,8 @@
 														))}
 												placeholder={placeholder ? placeholder : $i18n.t('Send a Message')}
 												largeTextAsFile={$settings?.largeTextAsFile ?? false}
-												autocomplete={$config?.features.enable_autocomplete_generation}
+												autocomplete={$config?.features?.enable_autocomplete_generation &&
+													($settings?.promptAutocomplete ?? false)}
 												generateAutoCompletion={async (text) => {
 													if (selectedModelIds.length === 0 || !selectedModelIds.at(0)) {
 														toast.error($i18n.t('Please select a model first.'));

+ 34 - 1
src/lib/components/chat/Settings/Interface.svelte

@@ -30,9 +30,12 @@
 	// Interface
 	let defaultModelId = '';
 	let showUsername = false;
+	let notificationSound = true;
+
 	let richTextInput = true;
+	let promptAutocomplete = false;
+
 	let largeTextAsFile = false;
-	let notificationSound = true;
 
 	let landingPageMode = '';
 	let chatBubble = true;
@@ -73,6 +76,11 @@
 		saveSettings({ splitLargeChunks: splitLargeChunks });
 	};
 
+	const togglePromptAutocomplete = async () => {
+		promptAutocomplete = !promptAutocomplete;
+		saveSettings({ promptAutocomplete: promptAutocomplete });
+	};
+
 	const togglesScrollOnBranchChange = async () => {
 		scrollOnBranchChange = !scrollOnBranchChange;
 		saveSettings({ scrollOnBranchChange: scrollOnBranchChange });
@@ -238,6 +246,7 @@
 		voiceInterruption = $settings.voiceInterruption ?? false;
 
 		richTextInput = $settings.richTextInput ?? true;
+		promptAutocomplete = $settings.promptAutocomplete ?? false;
 		largeTextAsFile = $settings.largeTextAsFile ?? false;
 
 		collapseCodeBlocks = $settings.collapseCodeBlocks ?? false;
@@ -564,6 +573,30 @@
 				</div>
 			</div>
 
+			{#if $config?.features?.enable_autocomplete_generation && richTextInput}
+				<div>
+					<div class=" py-0.5 flex w-full justify-between">
+						<div class=" self-center text-xs">
+							{$i18n.t('Prompt Autocompletion')}
+						</div>
+
+						<button
+							class="p-1 px-3 text-xs flex rounded-sm transition"
+							on:click={() => {
+								togglePromptAutocomplete();
+							}}
+							type="button"
+						>
+							{#if promptAutocomplete === true}
+								<span class="ml-2 self-center">{$i18n.t('On')}</span>
+							{:else}
+								<span class="ml-2 self-center">{$i18n.t('Off')}</span>
+							{/if}
+						</button>
+					</div>
+				</div>
+			{/if}
+
 			<div>
 				<div class=" py-0.5 flex w-full justify-between">
 					<div class=" self-center text-xs">