From 86105c0b5e2dd68a0d04a76a8c1529e99f63f593 Mon Sep 17 00:00:00 2001 From: BrutalCoding Date: Sun, 17 Sep 2023 06:35:04 +0800 Subject: [PATCH] feat: Added Chat prompt format (based off Alpaca) --- shady_ai_flutter/lib/data/prompt_config.dart | 5 +++ shady_ai_flutter/lib/main.dart | 43 +++++++++++++++++--- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/shady_ai_flutter/lib/data/prompt_config.dart b/shady_ai_flutter/lib/data/prompt_config.dart index 46107e2..f4beba6 100644 --- a/shady_ai_flutter/lib/data/prompt_config.dart +++ b/shady_ai_flutter/lib/data/prompt_config.dart @@ -22,6 +22,11 @@ class PromptConfig with _$PromptConfig { assistant: '', ); + static const alpaca = PromptConfig( + label: 'Chat', + defaultPromptFormat: "A chat.\nUSER: {prompt}\nASSISTANT:", + ); + static const none = PromptConfig( label: 'Empty', defaultPromptFormat: '', diff --git a/shady_ai_flutter/lib/main.dart b/shady_ai_flutter/lib/main.dart index d303b6c..69ee58e 100644 --- a/shady_ai_flutter/lib/main.dart +++ b/shady_ai_flutter/lib/main.dart @@ -355,16 +355,44 @@ class MyHomePage extends HookConsumerWidget { ), ), const SizedBox( - height: 16, + height: 32, ), const Text( 'This might take a while. Please wait.', ), const SizedBox( - height: 16, + height: 64, ), CircularProgressIndicator .adaptive(), + const SizedBox( + height: 64, + ), + Text( + 'Prompt template:', + style: Theme.of( + context, + ) + .textTheme + .titleLarge, + ), + const SizedBox( + height: 8, + ), + Text( + promptTemplate.value + .getCompletePrompt, + style: Theme.of( + context, + ) + .textTheme + .bodyMedium + ?.copyWith( + fontStyle: + FontStyle + .italic, + ), + ), ], ), ), @@ -389,8 +417,8 @@ class MyHomePage extends HookConsumerWidget { pathToFile: filePath.value, modelContextSize: promptTemplate .value.contextSize, - originalPrompt: promptTemplate - .value.getCompletePrompt, + originalPrompt: + promptTemplate.value, ); // Show response in a dialog @@ -402,7 +430,7 @@ class MyHomePage extends HookConsumerWidget { 'Response', ), content: Text( - response.response, + response, ), ); }, @@ -508,6 +536,11 @@ class MyHomePage extends HookConsumerWidget { promptTemplate.value = template; }, dropdownMenuEntries: [ + DropdownMenuEntry( + value: PromptConfig.alpaca, + label: + PromptConfig.alpaca.label, + ), DropdownMenuEntry( value: PromptConfig.synthia, label: