Skip to content

Commit

Permalink
Merge branch 'main' into reorganize-extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelrap committed May 24, 2024
2 parents d668a9b + ad5275c commit 7d69c33
Show file tree
Hide file tree
Showing 20 changed files with 1,496 additions and 102 deletions.
15 changes: 15 additions & 0 deletions assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3945,6 +3945,21 @@
"accuracy": "Accuracy",
"points": "Points",
"noPaymentInfo": "No payment info necessary!",
"conversationBotModeSelectDescription": "Bot mode",
"conversationBotModeSelectOption_discussion": "Discussion",
"conversationBotModeSelectOption_custom": "Custom",
"conversationBotModeSelectOption_conversation": "Conversation",
"conversationBotModeSelectOption_textAdventure": "Text Adventure",
"conversationBotDiscussionZone_title": "Discussion Settings",
"conversationBotDiscussionZone_discussionTopicLabel": "Discussion Topic",
"conversationBotDiscussionZone_discussionTopicPlaceholder": "Set Discussion Topic",
"conversationBotDiscussionZone_discussionKeywordsLabel": "Discussion Keywords",
"conversationBotDiscussionZone_discussionKeywordsPlaceholder": "Set Discussion Keywords",
"conversationBotDiscussionZone_discussionKeywordsHintText": "Comma separated list of keywords to guide the discussion",
"conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel": "Send discussion prompt on a schedule",
"conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Hours between discussion prompts",
"conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Send discussion prompt when user reacts ⏩ to bot message",
"conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reaction to send discussion prompt",
"studentAnalyticsNotAvailable": "Student data not currently available",
"roomDataMissing": "Some data may be missing from rooms in which you are not a member.",
"updatePhoneOS": "You may need to update your device's OS version.",
Expand Down
19 changes: 18 additions & 1 deletion assets/l10n/intl_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -4634,5 +4634,22 @@
"points": "Puntos",
"noPaymentInfo": "No se necesitan datos de pago.",
"updatePhoneOS": "Puede que necesites actualizar la versión del sistema operativo de tu dispositivo.",
"wordsPerMinute": "Palabras por minuto"
"wordsPerMinute": "Palabras por minuto",
"conversationBotModeSelectDescription": "Modo bot",
"conversationBotModeSelectOption_discussion": "Debate",
"conversationBotModeSelectOption_custom": "A medida",
"conversationBotModeSelectOption_conversation": "Conversación",
"conversationBotModeSelectOption_textAdventure": "Aventura textual",
"conversationBotDiscussionZone_title": "Configuración del debate",
"conversationBotDiscussionZone_discussionTopicLabel": "Tema de debate",
"conversationBotDiscussionZone_discussionTopicPlaceholder": "Establecer tema de debate",
"conversationBotDiscussionZone_discussionKeywordsLabel": "Palabras clave del debate",
"conversationBotDiscussionZone_discussionKeywordsPlaceholder": "Establecer palabras clave de debate",
"conversationBotDiscussionZone_discussionKeywordsHintText": "Lista de palabras clave separadas por comas para orientar el debate",
"conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel": "Enviar mensajes de debate según un calendario",
"conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Horas entre temas de debate",
"conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Enviar aviso de discusión cuando el usuario reacciona ⏩ al mensaje del bot.",
"conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reacción al envío del aviso de debate",
"studentAnalyticsNotAvailable": "Datos de los estudiantes no disponibles actualmente",
"roomDataMissing": "Es posible que falten algunos datos de las salas de las que no es miembro."
}
6 changes: 5 additions & 1 deletion lib/pangea/choreographer/controllers/igc_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ class IgcController {
),
);

igcTextData!.matches[matchIndex].match = response.span;
try {
igcTextData!.matches[matchIndex].match = response.span;
} catch (err, s) {
ErrorHandler.logError(e: err, s: s);
}

choreographer.setState();
}
Expand Down
14 changes: 12 additions & 2 deletions lib/pangea/constants/model_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,17 @@ class ModelKey {

// bot options
static const String languageLevel = "difficulty";
static const String conversationTopic = "conversation_topic";
static const String keywords = "keywords";
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 discussionTriggerScheduleEnabled =
"discussion_trigger_schedule_enabled";
static const String discussionTriggerScheduleHourInterval =
"discussion_trigger_schedule_hour_interval";
static const String discussionTriggerReactionEnabled =
"discussion_trigger_reaction_enabled";
static const String discussionTriggerReactionKey =
"discussion_trigger_reaction_key";
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ extension PangeaClient2 on Client {
.toList();

Future<List<Room>> get _classesAndExchangesImTeaching async {
for (final Room space in rooms.where((room) => room.isSpace)) {
final allSpaces = rooms.where((room) => room.isSpace);
for (final Room space in allSpaces) {
if (space.getState(EventTypes.RoomPowerLevels) == null) {
await space.postLoad();
}
Expand Down
73 changes: 63 additions & 10 deletions lib/pangea/models/bot_options_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,45 @@ class BotOptionsModel {
String topic;
List<String> keywords;
bool safetyModeration;
String mode;
String? custom;
String? discussionTopic;
String? discussionKeywords;
bool? discussionTriggerScheduleEnabled;
int? discussionTriggerScheduleHourInterval;
bool? discussionTriggerReactionEnabled;
String? discussionTriggerReactionKey;

BotOptionsModel({
this.languageLevel,
this.topic = "General Conversation",
this.keywords = const [],
this.safetyModeration = true,
this.mode = "discussion",
this.custom = "",
this.discussionTopic,
this.discussionKeywords,
this.discussionTriggerScheduleEnabled,
this.discussionTriggerScheduleHourInterval,
this.discussionTriggerReactionEnabled,
this.discussionTriggerReactionKey,
});

factory BotOptionsModel.fromJson(json) {
return BotOptionsModel(
languageLevel: json[ModelKey.languageLevel],
topic: json[ModelKey.conversationTopic] ?? "General Conversation",
keywords: (json[ModelKey.keywords] ?? []).cast<String>(),
safetyModeration: json[ModelKey.safetyModeration] ?? true,
mode: json[ModelKey.mode] ?? "discussion",
custom: json[ModelKey.custom],
discussionTopic: json[ModelKey.discussionTopic],
discussionKeywords: json[ModelKey.discussionKeywords],
discussionTriggerScheduleEnabled:
json[ModelKey.discussionTriggerScheduleEnabled],
discussionTriggerScheduleHourInterval:
json[ModelKey.discussionTriggerScheduleHourInterval],
discussionTriggerReactionEnabled:
json[ModelKey.discussionTriggerReactionEnabled],
discussionTriggerReactionKey: json[ModelKey.discussionTriggerReactionKey],
);
}

Expand All @@ -34,9 +59,19 @@ class BotOptionsModel {
try {
// data[ModelKey.isConversationBotChat] = isConversationBotChat;
data[ModelKey.languageLevel] = languageLevel;
data[ModelKey.conversationTopic] = topic;
data[ModelKey.keywords] = keywords;
data[ModelKey.safetyModeration] = safetyModeration;
data[ModelKey.mode] = mode;
data[ModelKey.custom] = custom;
data[ModelKey.discussionTopic] = discussionTopic;
data[ModelKey.discussionKeywords] = discussionKeywords;
data[ModelKey.discussionTriggerScheduleEnabled] =
discussionTriggerScheduleEnabled;
data[ModelKey.discussionTriggerScheduleHourInterval] =
discussionTriggerScheduleHourInterval;
data[ModelKey.discussionTriggerReactionEnabled] =
discussionTriggerReactionEnabled;
data[ModelKey.discussionTriggerReactionKey] =
discussionTriggerReactionKey;
return data;
} catch (e, s) {
debugger(when: kDebugMode);
Expand All @@ -51,15 +86,33 @@ class BotOptionsModel {
case ModelKey.languageLevel:
languageLevel = value;
break;
case ModelKey.conversationTopic:
topic = value;
break;
case ModelKey.keywords:
keywords = value;
break;
case ModelKey.safetyModeration:
safetyModeration = value;
break;
case ModelKey.mode:
mode = value;
break;
case ModelKey.custom:
custom = value;
break;
case ModelKey.discussionTopic:
discussionTopic = value;
break;
case ModelKey.discussionKeywords:
discussionKeywords = value;
break;
case ModelKey.discussionTriggerScheduleEnabled:
discussionTriggerScheduleEnabled = value;
break;
case ModelKey.discussionTriggerScheduleHourInterval:
discussionTriggerScheduleHourInterval = value;
break;
case ModelKey.discussionTriggerReactionEnabled:
discussionTriggerReactionEnabled = value;
break;
case ModelKey.discussionTriggerReactionKey:
discussionTriggerReactionKey = value;
break;
default:
throw Exception('Invalid key for bot options - $key');
}
Expand Down
11 changes: 0 additions & 11 deletions lib/pangea/models/representation_content_model.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import 'package:fluffychat/pangea/constants/language_keys.dart';
import 'package:fluffychat/pangea/models/speech_to_text_models.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:matrix/matrix.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

/// this class is contained within a [RepresentationEvent]
/// this event is the child of a [EventTypes.Message]
Expand Down Expand Up @@ -56,14 +53,6 @@ class PangeaRepresentation {
});

factory PangeaRepresentation.fromJson(Map<String, dynamic> json) {
if (json[_langCodeKey] == LanguageKeys.unknownLanguage) {
ErrorHandler.logError(
e: Exception("Language code cannot be 'unk'"),
s: StackTrace.current,
data: {"rep_content": json},
level: SentryLevel.warning,
);
}
return PangeaRepresentation(
langCode: json[_langCodeKey],
text: json[_textKey],
Expand Down
17 changes: 15 additions & 2 deletions lib/pangea/models/span_card_model.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
import 'package:fluffychat/pangea/models/pangea_match_model.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart';

class SpanCardModel {
// IGCTextData igcTextData;
Expand All @@ -21,6 +22,18 @@ class SpanCardModel {
required this.choreographer,
});

PangeaMatch? get pangeaMatch =>
choreographer.igc.igcTextData?.matches[matchIndex];
PangeaMatch? get pangeaMatch {
if (choreographer.igc.igcTextData == null) return null;
if (matchIndex >= choreographer.igc.igcTextData!.matches.length) {
ErrorHandler.logError(
m: "matchIndex out of bounds in span card",
data: {
"matchIndex": matchIndex,
"matchesLength": choreographer.igc.igcTextData?.matches.length,
},
);
return null;
}
return choreographer.igc.igcTextData?.matches[matchIndex];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';

class ConversationBotConversationZone extends StatelessWidget {
const ConversationBotConversationZone({
super.key,
});

@override
Widget build(BuildContext context) {
return const Column(
children: [
Text('Conversation Zone'),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';

class ConversationBotCustomZone extends StatelessWidget {
const ConversationBotCustomZone({
super.key,
});

@override
Widget build(BuildContext context) {
return const Column(
children: [
Text('Custom Zone'),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import 'package:fluffychat/pangea/models/bot_options_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';

class ConversationBotDiscussionKeywordsInput extends StatelessWidget {
final BotOptionsModel initialBotOptions;
// call this to update propagate changes to parents
final void Function(BotOptionsModel) onChanged;

const ConversationBotDiscussionKeywordsInput({
super.key,
required this.initialBotOptions,
required this.onChanged,
});

@override
Widget build(BuildContext context) {
String discussionKeywords = initialBotOptions.discussionKeywords ?? "";

final TextEditingController textFieldController =
TextEditingController(text: discussionKeywords);

void setBotDiscussionKeywordsAction() async {
showDialog(
context: context,
useRootNavigator: false,
builder: (BuildContext context) => AlertDialog(
title: Text(
L10n.of(context)!
.conversationBotDiscussionZone_discussionKeywordsLabel,
),
content: TextField(
controller: textFieldController,
onChanged: (value) {
discussionKeywords = value;
},
),
actions: [
TextButton(
child: Text(L10n.of(context)!.cancel),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text(L10n.of(context)!.ok),
onPressed: () {
if (discussionKeywords == "") return;
if (discussionKeywords !=
initialBotOptions.discussionKeywords) {
initialBotOptions.discussionKeywords = discussionKeywords;
onChanged.call(initialBotOptions);
Navigator.of(context).pop();
}
},
),
],
),
);
}

return ListTile(
onTap: setBotDiscussionKeywordsAction,
title: Text(
initialBotOptions.discussionKeywords ??
L10n.of(context)!
.conversationBotDiscussionZone_discussionKeywordsPlaceholder,
),
);
}
}
Loading

0 comments on commit 7d69c33

Please sign in to comment.