add custom mode and propagate user inputs to state events
This commit is contained in:
parent
dec0c23523
commit
aab10ff613
5 changed files with 22 additions and 23 deletions
|
|
@ -99,7 +99,6 @@ class ModelKey {
|
|||
static const String languageLevel = "difficulty";
|
||||
static const String safetyModeration = "safety_moderation";
|
||||
static const String mode = "mode";
|
||||
static const String custom = "custom";
|
||||
static const String discussionTopic = "discussion_topic";
|
||||
static const String discussionKeywords = "discussion_keywords";
|
||||
static const String discussionTriggerReactionEnabled =
|
||||
|
|
|
|||
|
|
@ -13,14 +13,13 @@ class BotOptionsModel {
|
|||
List<String> keywords;
|
||||
bool safetyModeration;
|
||||
String mode;
|
||||
String? custom;
|
||||
String? discussionTopic;
|
||||
String? discussionKeywords;
|
||||
bool discussionTriggerReactionEnabled;
|
||||
String discussionTriggerReactionKey;
|
||||
bool? discussionTriggerReactionEnabled;
|
||||
String? discussionTriggerReactionKey;
|
||||
String? customSystemPrompt;
|
||||
bool customTriggerReactionEnabled;
|
||||
String customTriggerReactionKey;
|
||||
bool? customTriggerReactionEnabled;
|
||||
String? customTriggerReactionKey;
|
||||
|
||||
BotOptionsModel({
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -63,15 +62,17 @@ class BotOptionsModel {
|
|||
discussionTopic: json[ModelKey.discussionTopic],
|
||||
discussionKeywords: json[ModelKey.discussionKeywords],
|
||||
discussionTriggerReactionEnabled:
|
||||
json[ModelKey.discussionTriggerReactionEnabled],
|
||||
discussionTriggerReactionKey: json[ModelKey.discussionTriggerReactionKey],
|
||||
json[ModelKey.discussionTriggerReactionEnabled] ?? true,
|
||||
discussionTriggerReactionKey:
|
||||
json[ModelKey.discussionTriggerReactionKey] ?? "⏩",
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Custom Mode Options
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
customSystemPrompt: json[ModelKey.customSystemPrompt],
|
||||
customTriggerReactionEnabled: json[ModelKey.customTriggerReactionEnabled],
|
||||
customTriggerReactionKey: json[ModelKey.customTriggerReactionKey],
|
||||
customTriggerReactionEnabled:
|
||||
json[ModelKey.customTriggerReactionEnabled] ?? true,
|
||||
customTriggerReactionKey: json[ModelKey.customTriggerReactionKey] ?? "⏩",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -82,17 +83,16 @@ class BotOptionsModel {
|
|||
data[ModelKey.languageLevel] = languageLevel;
|
||||
data[ModelKey.safetyModeration] = safetyModeration;
|
||||
data[ModelKey.mode] = mode;
|
||||
data[ModelKey.custom] = custom;
|
||||
data[ModelKey.discussionTopic] = discussionTopic;
|
||||
data[ModelKey.discussionKeywords] = discussionKeywords;
|
||||
data[ModelKey.discussionTriggerReactionEnabled] =
|
||||
discussionTriggerReactionEnabled;
|
||||
discussionTriggerReactionEnabled ?? true;
|
||||
data[ModelKey.discussionTriggerReactionKey] =
|
||||
discussionTriggerReactionKey;
|
||||
discussionTriggerReactionKey ?? "⏩";
|
||||
data[ModelKey.customSystemPrompt] = customSystemPrompt;
|
||||
data[ModelKey.customTriggerReactionEnabled] =
|
||||
customTriggerReactionEnabled;
|
||||
data[ModelKey.customTriggerReactionKey] = customTriggerReactionKey;
|
||||
customTriggerReactionEnabled ?? true;
|
||||
data[ModelKey.customTriggerReactionKey] = customTriggerReactionKey ?? "⏩";
|
||||
return data;
|
||||
} catch (e, s) {
|
||||
debugger(when: kDebugMode);
|
||||
|
|
@ -113,9 +113,6 @@ class BotOptionsModel {
|
|||
case ModelKey.mode:
|
||||
mode = value;
|
||||
break;
|
||||
case ModelKey.custom:
|
||||
custom = value;
|
||||
break;
|
||||
case ModelKey.discussionTopic:
|
||||
discussionTopic = value;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class ConversationBotCustomZone extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print(initialBotOptions.toJson());
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
|
|
@ -59,9 +60,9 @@ class ConversationBotCustomZone extends StatelessWidget {
|
|||
.conversationBotCustomZone_customTriggerReactionEnabledLabel,
|
||||
),
|
||||
enabled: false,
|
||||
value: initialBotOptions.customTriggerReactionEnabled,
|
||||
value: initialBotOptions.customTriggerReactionEnabled ?? true,
|
||||
onChanged: (value) {
|
||||
initialBotOptions.customTriggerReactionEnabled = value ?? false;
|
||||
initialBotOptions.customTriggerReactionEnabled = value ?? true;
|
||||
initialBotOptions.customTriggerReactionKey =
|
||||
"⏩"; // hard code this for now
|
||||
onChanged.call(initialBotOptions);
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ class ConversationBotDiscussionZone extends StatelessWidget {
|
|||
.conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel,
|
||||
),
|
||||
enabled: false,
|
||||
value: initialBotOptions.discussionTriggerReactionEnabled ?? false,
|
||||
value: initialBotOptions.discussionTriggerReactionEnabled ?? true,
|
||||
onChanged: (value) {
|
||||
initialBotOptions.discussionTriggerReactionEnabled = value ?? false;
|
||||
initialBotOptions.discussionTriggerReactionEnabled = value ?? true;
|
||||
initialBotOptions.discussionTriggerReactionKey =
|
||||
"⏩"; // hard code this for now
|
||||
onChanged.call(initialBotOptions);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ class ConversationBotSettingsState extends State<ConversationBotSettings> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
isOpen = widget.startOpen;
|
||||
botOptions = widget.room?.botOptions ?? BotOptionsModel();
|
||||
botOptions = widget.room?.botOptions != null
|
||||
? BotOptionsModel.fromJson(widget.room?.botOptions?.toJson())
|
||||
: BotOptionsModel();
|
||||
widget.room?.isBotRoom.then((bool isBotRoom) {
|
||||
setState(() {
|
||||
addBot = isBotRoom;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue