Skip to content

Commit

Permalink
feat: make chatbot configurable (#1)
Browse files Browse the repository at this point in the history
* build: temporarily comment part of vite config

* build: change CRLF line endings to LF

* feat: builder view prototype

* feat: use Settings in Player View

* feat: multiline input fields

* feat: add tabs including assistant settings

* feat: add colors to different exchanges and assistant settings

* feat: add create at least one assistant warning

* feat: possible to move panels up and down

* feat: add assistant image icons

* feat: add uuid ids to elements

* feat: make arrows same color as panels

* feat: add maxima to inputs

* feat: add tooltip for arrows

* feat: uses current User

* fix: remove useData function

* feat: conserve chats when reloaded

* feat: autofocus on text area

* fix: remove console log lines

* fix: remove outdated comments and files

* fix: use intersection types for duplicate code

* feat: add message on ending of exchanges

* fix: optimize number of passed parameters

* feat: add comments

* fix: move up dissmissExchange function from message input to message pane

* fix: remove infinte rerender of messages

* feat: updated prompt sent to chatbot

* fix: stop hiding default avatar symbol

* feat: add function descriptions

* fix: correct dismissExchange function description

* feat: add view conversations tab

* fix: correct errors commented in PR including typos and double variables

* fix: stop showing conversations results twice

* fix: don't show banner with instructions on complete of exchange in the conversations view
  • Loading branch information
deRohrer authored Aug 30, 2024
1 parent baf5f62 commit e138776
Show file tree
Hide file tree
Showing 28 changed files with 1,752 additions and 638 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ yarn-debug.log*
cypress/screenshots/
cypress/videos/
cypress/downloads/

#vite
vite.config.ts.timestamp-*
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"endOfLine": "auto"
}
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
compressionLevel: mixed

defaultSemverRangePrefix: ""
defaultSemverRangePrefix: ''

enableGlobalCache: false

Expand Down
60 changes: 29 additions & 31 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,37 @@

## 1.0.0 (2024-04-14)


### Features

* add one thread and auto dismiss options ([273b267](https://github.com/graasp/graasp-app-botticelli/commit/273b267e17931f6f5f5fa28a6b01aba4774dc1ed))
* add scrolling ([3d09ac7](https://github.com/graasp/graasp-app-botticelli/commit/3d09ac76d51e94c930fcd73aeda6ba7466052824))
* blur after sending message ([13f83e6](https://github.com/graasp/graasp-app-botticelli/commit/13f83e6283031b08f5be15d9202429f92e6df7d9))
* improve prompts ([bbfca97](https://github.com/graasp/graasp-app-botticelli/commit/bbfca970479a9b655c2d2863dc640e4856020ba6))
* make height full viewport ([ef95461](https://github.com/graasp/graasp-app-botticelli/commit/ef95461d54c569ec6c7390537965e794e1d0ad65))
* save app data ([6db1c6a](https://github.com/graasp/graasp-app-botticelli/commit/6db1c6a0228544eedfdbf50e9dd512932fd4aac7))
* save chat in session storage ([c8c6ed0](https://github.com/graasp/graasp-app-botticelli/commit/c8c6ed046fe36cfb6eedae3ed2e9e775b94bedfe))
* show warning on unload ([3435ddf](https://github.com/graasp/graasp-app-botticelli/commit/3435ddfd840b697487c5db8c644796e8e09e0dca))
* update prompt ([3736f05](https://github.com/graasp/graasp-app-botticelli/commit/3736f05ce53fa10b491f981fe9d1213472f3241e))

- add one thread and auto dismiss options ([273b267](https://github.com/graasp/graasp-app-botticelli/commit/273b267e17931f6f5f5fa28a6b01aba4774dc1ed))
- add scrolling ([3d09ac7](https://github.com/graasp/graasp-app-botticelli/commit/3d09ac76d51e94c930fcd73aeda6ba7466052824))
- blur after sending message ([13f83e6](https://github.com/graasp/graasp-app-botticelli/commit/13f83e6283031b08f5be15d9202429f92e6df7d9))
- improve prompts ([bbfca97](https://github.com/graasp/graasp-app-botticelli/commit/bbfca970479a9b655c2d2863dc640e4856020ba6))
- make height full viewport ([ef95461](https://github.com/graasp/graasp-app-botticelli/commit/ef95461d54c569ec6c7390537965e794e1d0ad65))
- save app data ([6db1c6a](https://github.com/graasp/graasp-app-botticelli/commit/6db1c6a0228544eedfdbf50e9dd512932fd4aac7))
- save chat in session storage ([c8c6ed0](https://github.com/graasp/graasp-app-botticelli/commit/c8c6ed046fe36cfb6eedae3ed2e9e775b94bedfe))
- show warning on unload ([3435ddf](https://github.com/graasp/graasp-app-botticelli/commit/3435ddfd840b697487c5db8c644796e8e09e0dca))
- update prompt ([3736f05](https://github.com/graasp/graasp-app-botticelli/commit/3736f05ce53fa10b491f981fe9d1213472f3241e))

### Bug Fixes

* attempt to make warning work on mobile ([7333e99](https://github.com/graasp/graasp-app-botticelli/commit/7333e99e25d4bcfe2aa23d03087412ac61ecbd2f))
* **deps:** update dependency @emotion/styled to v11.11.5 ([ed3c6f1](https://github.com/graasp/graasp-app-botticelli/commit/ed3c6f1cb205b94e8063c18736541b6dbf4c162d))
* **deps:** update dependency @graasp/apps-query-client to v3.4.10 ([ff23dbb](https://github.com/graasp/graasp-app-botticelli/commit/ff23dbb6b35c5d42ea5dc2de2aa8f89e3e4b8a4e))
* **deps:** update dependency @graasp/sdk to v4.6.0 ([03c8d5f](https://github.com/graasp/graasp-app-botticelli/commit/03c8d5f45c19b5995be54ddc9d99b872c828cb3b))
* **deps:** update dependency @graasp/sdk to v4.7.1 ([afd90bb](https://github.com/graasp/graasp-app-botticelli/commit/afd90bb6ee850a7290c45bb6b1fa2ce8dced000e))
* **deps:** update dependency @types/react to v18.2.75 ([54c503e](https://github.com/graasp/graasp-app-botticelli/commit/54c503e35dc864f3b3f0d4e42fbee2e41f67d057))
* **deps:** update dependency typescript to v5.4.4 ([ce757e6](https://github.com/graasp/graasp-app-botticelli/commit/ce757e6cc1b2303a6be614622a1e9cd77238e749))
* **deps:** update dependency typescript to v5.4.5 ([7c24658](https://github.com/graasp/graasp-app-botticelli/commit/7c24658a953a2ecace3394dcd038871410fbf73c))
* **deps:** update mui (non-major) ([d206f8d](https://github.com/graasp/graasp-app-botticelli/commit/d206f8daf8be8562a76f47208fe287e028191e1f))
* **deps:** update react monorepo ([ed7e82a](https://github.com/graasp/graasp-app-botticelli/commit/ed7e82ad865b207b0a71a37d960b996bf7793af3))
* **deps:** update react monorepo ([7fe3b03](https://github.com/graasp/graasp-app-botticelli/commit/7fe3b03771a347dc670816a6615c60d2c289b9a8))
* fix player view test ([365ee8a](https://github.com/graasp/graasp-app-botticelli/commit/365ee8a0c79a1dd80b4742c148adae248809d250))
* fix prompt builder helper ([c0f453a](https://github.com/graasp/graasp-app-botticelli/commit/c0f453a5be8a32773e16aaabf6c7a5079af79800))
* fix size of instructions ([f12013d](https://github.com/graasp/graasp-app-botticelli/commit/f12013d6dee686e17b45cfc827309fb9525287af))
* fix tests ([8955748](https://github.com/graasp/graasp-app-botticelli/commit/895574856d7b3dc53f096804fc89f273e9dd5cf2))
* fix window access ([78b7519](https://github.com/graasp/graasp-app-botticelli/commit/78b7519f75149093773c82156ac675138d061226))
* remove autoscrolling ([b6a1a06](https://github.com/graasp/graasp-app-botticelli/commit/b6a1a0615eba2b136515e41291af13826ca7df6e))
* set status to idle after response ([6084db3](https://github.com/graasp/graasp-app-botticelli/commit/6084db3e483e2db3e7b18f3a232eb2a9b8bf903b))
* update cues ([568ff8a](https://github.com/graasp/graasp-app-botticelli/commit/568ff8aec44dcd7e506850b5badc068ff8599490))
* update text ([a34c545](https://github.com/graasp/graasp-app-botticelli/commit/a34c5459e78fb53b5c871cd134f29e49dd7062f0))
- attempt to make warning work on mobile ([7333e99](https://github.com/graasp/graasp-app-botticelli/commit/7333e99e25d4bcfe2aa23d03087412ac61ecbd2f))
- **deps:** update dependency @emotion/styled to v11.11.5 ([ed3c6f1](https://github.com/graasp/graasp-app-botticelli/commit/ed3c6f1cb205b94e8063c18736541b6dbf4c162d))
- **deps:** update dependency @graasp/apps-query-client to v3.4.10 ([ff23dbb](https://github.com/graasp/graasp-app-botticelli/commit/ff23dbb6b35c5d42ea5dc2de2aa8f89e3e4b8a4e))
- **deps:** update dependency @graasp/sdk to v4.6.0 ([03c8d5f](https://github.com/graasp/graasp-app-botticelli/commit/03c8d5f45c19b5995be54ddc9d99b872c828cb3b))
- **deps:** update dependency @graasp/sdk to v4.7.1 ([afd90bb](https://github.com/graasp/graasp-app-botticelli/commit/afd90bb6ee850a7290c45bb6b1fa2ce8dced000e))
- **deps:** update dependency @types/react to v18.2.75 ([54c503e](https://github.com/graasp/graasp-app-botticelli/commit/54c503e35dc864f3b3f0d4e42fbee2e41f67d057))
- **deps:** update dependency typescript to v5.4.4 ([ce757e6](https://github.com/graasp/graasp-app-botticelli/commit/ce757e6cc1b2303a6be614622a1e9cd77238e749))
- **deps:** update dependency typescript to v5.4.5 ([7c24658](https://github.com/graasp/graasp-app-botticelli/commit/7c24658a953a2ecace3394dcd038871410fbf73c))
- **deps:** update mui (non-major) ([d206f8d](https://github.com/graasp/graasp-app-botticelli/commit/d206f8daf8be8562a76f47208fe287e028191e1f))
- **deps:** update react monorepo ([ed7e82a](https://github.com/graasp/graasp-app-botticelli/commit/ed7e82ad865b207b0a71a37d960b996bf7793af3))
- **deps:** update react monorepo ([7fe3b03](https://github.com/graasp/graasp-app-botticelli/commit/7fe3b03771a347dc670816a6615c60d2c289b9a8))
- fix player view test ([365ee8a](https://github.com/graasp/graasp-app-botticelli/commit/365ee8a0c79a1dd80b4742c148adae248809d250))
- fix prompt builder helper ([c0f453a](https://github.com/graasp/graasp-app-botticelli/commit/c0f453a5be8a32773e16aaabf6c7a5079af79800))
- fix size of instructions ([f12013d](https://github.com/graasp/graasp-app-botticelli/commit/f12013d6dee686e17b45cfc827309fb9525287af))
- fix tests ([8955748](https://github.com/graasp/graasp-app-botticelli/commit/895574856d7b3dc53f096804fc89f273e9dd5cf2))
- fix window access ([78b7519](https://github.com/graasp/graasp-app-botticelli/commit/78b7519f75149093773c82156ac675138d061226))
- remove autoscrolling ([b6a1a06](https://github.com/graasp/graasp-app-botticelli/commit/b6a1a0615eba2b136515e41291af13826ca7df6e))
- set status to idle after response ([6084db3](https://github.com/graasp/graasp-app-botticelli/commit/6084db3e483e2db3e7b18f3a232eb2a9b8bf903b))
- update cues ([568ff8a](https://github.com/graasp/graasp-app-botticelli/commit/568ff8aec44dcd7e506850b5badc068ff8599490))
- update text ([a34c545](https://github.com/graasp/graasp-app-botticelli/commit/a34c5459e78fb53b5c871cd134f29e49dd7062f0))
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ A version of Botticelli's participant interface that runs on the Graasp platform

### Credits

Uses Graasp's app template as a starter.
Uses Graasp's app template as a starter.
2 changes: 1 addition & 1 deletion cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
17 changes: 12 additions & 5 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>graasp/renovate-config:app"
],
"extends": ["github>graasp/renovate-config:app"],
"packageRules": [
{
"matchDepTypes": ["devDependencies"],
"matchPackagePatterns": ["lint", "prettier", "vite", "cypress", "commitlint", "axios", "concurrently", "env"],
"matchPackagePatterns": [
"lint",
"prettier",
"vite",
"cypress",
"commitlint",
"axios",
"concurrently",
"env"
],
"automerge": true
},
{
"matchUpdateTypes": ["minor","patch"],
"matchUpdateTypes": ["minor", "patch"],
"matchCurrentVersion": "!/^0/",
"automerge": true
}
Expand Down
4 changes: 0 additions & 4 deletions src/config/appData.ts

This file was deleted.

28 changes: 28 additions & 0 deletions src/config/appSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { UUID } from '@graasp/sdk';

import Agent from '@/types/Agent';

type AssistantSettings = Omit<Agent, 'type'>;

export type AssistantsSettingsType = {
assistantList: AssistantSettings[];
};

export type ChatSettingsType = {
description: string;
participantInstructions: string;
participantEndText: string;
};

export type ExchangeSettings = {
id: UUID;
assistant: AssistantSettings;
description: string;
chatbotInstructions: string;
participantCue: string;
nbFollowUpQuestions: number;
participantInstructionsOnComplete?: string;
hardLimit: boolean;
};

export type ExchangesSettingsType = { exchangeList: ExchangeSettings[] };
61 changes: 61 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Member } from '@graasp/sdk';

import { t } from 'i18next';
import { v4 as uuidv4 } from 'uuid';

import { defaultSettingsValues } from '@/modules/context/SettingsContext';
import Agent from '@/types/Agent';
import AgentType from '@/types/AgentType';
import Exchange from '@/types/Exchange';
import Interaction from '@/types/Interaction';

export const MIN_FOLLOW_UP_QUESTIONS: number = 0;
export const MAX_FOLLOW_UP_QUESTIONS: number = 400;
export const MAX_TEXT_INPUT_CHARS: number = 5000;

// Define a default user as an agent
export const defaultUser: Agent = {
id: uuidv4(),
name: 'Default User',
description: 'Default user description',
type: AgentType.User,
};

// Define a default assistant as an agent
export const defaultAssistant: Agent = {
id: uuidv4(),
name: 'Default Assistant',
description: 'Default assistant description',
type: AgentType.Assistant,
};

// Define a default interaction object using default settings
export const defaultInteraction: Interaction = {
...defaultSettingsValues.chat,
id: uuidv4(),
currentExchange: 0,
started: false,
completed: false,
participant: defaultUser,
exchanges: { exchangeList: [] },
createdAt: new Date(),
updatedAt: new Date(),
};

// Define a default exchange object using default settings
export const defaultExchange: Exchange = {
...defaultSettingsValues.exchanges.exchangeList[0],
messages: [],
assistant: defaultAssistant,
started: false,
completed: false,
dismissed: false,
createdAt: new Date(),
updatedAt: new Date(),
};

export const placeholderMember: Member = {
id: '',
name: t('CONVERSATIONS.PLACEHOLDER'),
email: '',
};
2 changes: 1 addition & 1 deletion src/config/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ i18n.use(initReactI18next).init({
debug: import.meta.env.DEV,
ns: [defaultNS],
defaultNS,
keySeparator: false,
keySeparator: '.',
interpolation: {
escapeValue: false,
formatSeparator: ',',
Expand Down
2 changes: 0 additions & 2 deletions src/config/messages.ts

This file was deleted.

53 changes: 52 additions & 1 deletion src/langs/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"translations": {
"Welcome to the Graasp App Starter Kit": "Welcome to the Graasp App Starter Kit",
"ERROR_BOUNDARY": {
"FALLBACK": {
"MESSAGE_TITLE": "Sorry, something went wrong with this application",
Expand All @@ -15,6 +14,58 @@
"THANKS_FOR_FEEDBACK": "Thank you for your feedback!",
"SEND": "Send your feedback"
}
},
"SETTINGS": {
"TITLE": "App Settings",
"SAVE_BTN": "Save",
"UP": "Move up",
"DOWN": "Move down",
"ASSISTANTS": {
"TITLE": "Assistants Settings",
"ID": "Assistant ID",
"NAME": "Assistant Name",
"DESCRIPTION": "Assistant Description",
"IMAGE": "Assistant Image",
"URL": "Please enter a working link to your desired image.",
"ADD": "Create New Assistant",
"CREATE": "Please create at least one assistant."
},
"CHAT": {
"TITLE": "Chat Settings",
"DESCRIPTION": "Chat Description",
"INSTRUCTIONS": "Participant Instructions",
"END": "End Screen Text",
"USER": "Participant"
},
"EXCHANGES": {
"TITLE": "Exchanges Settings",
"DESCRIPTION": "Exchanges Description",
"INSTRUCTIONS": "Chatbot instructions",
"CUE": "Initial Cue",
"ASSISTANT": "Assistant",
"CREATE_ASSISTANT": "Please create at least one assistant.",
"FOLLOW_UP_QUESTIONS": "Number of Follow Up Questions",
"ON_COMPLETE": "Instruction on Exchange Completion",
"ON_COMPLETE_HELPER": "This text will be shown once the given number of follow up questions have been answered. Leave blank for no message.",
"DISABLE_HARD_LIMIT": "Auto Dismiss",
"HARD_LIMIT_INFO": "If checked, the next exchange will start automatically after the number of follow up questions is reached.",
"CREATE": "Please create at least one exchange."
}
},
"CONVERSATIONS": {
"TITLE": "View Conversations",
"MEMBER": "Please select a member",
"PLACEHOLDER": "Please select a member",
"NONE": "No conversations so far.",
"COMPLETE": "Completed",
"INCOMPLETE": "Not completed",
"RESET": "Delete and reset conversation"
},
"START": "Start",
"MESSAGE_BOX": {
"INSERT_HERE": "Your response here...",
"SEND": "Send",
"DONE": "Done"
}
}
}
68 changes: 67 additions & 1 deletion src/langs/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,71 @@
{
"translations": {
"Welcome to the Graasp App Starter Kit": "Bienvenue dans le kit de démarrage de l'application Graasp"
"ERROR_BOUNDARY": {
"FALLBACK": {
"MESSAGE_TITLE": "Désolé, quelque chose n'a pas fonctionné avec cette application",
"MESSAGE_FEEDBACK": "Notre équipe a été informée. Si vous souhaitez nous aider, veuillez nous expliquer ce qui s'est passé ci-dessous",
"ERROR_DETAILS": "Détails de l'erreur",
"NAME_LABEL": "Name",
"NAME_HELPER": "Fournissez votre nom (facultatif)",
"EMAIL_LABEL": "Email",
"EMAIL_HELPER": "Fournissez votre courriel (facultatif)",
"COMMENT_LABEL": "Commentaire",
"COMMENT_HELPER": "Racontez-nous ce qui s'est passé (facultatif)",
"THANKS_FOR_FEEDBACK": "Thank you for your feedback !",
"SEND": "Envoyez votre retour d'information"
}
},
"SETTINGS": {
"TITLE": "Paramètres de l'application",
"SAVE_BTN": "Enregistrer",
"UP": "Déplacer vers le haut",
"DOWN": "Déplacer vers le bas",
"ASSISTANTS": {
"TITLE": "Paramètres de l'Assistant",
"ID": "Assistant ID",
"NAME": "Nom de l'Assistant",
"DESCRIPTION": "Description de l'Assistant",
"IMAGE": "Image de l'Assistant",
"URL": "Veuillez saisir un lien fonctionnel vers l'image souhaitée.",
"ADD": "Créer un Nouvel Assistant",
"CREATE": "Veuillez créer au moins un assistant."
},
"CHAT": {
"TITLE": " Paramètres du Chat",
"DESCRIPTION": "Description du Chat",
"INSTRUCTIONS": "Instructions pour le Participant",
"END": "Texte de Fin d'Écran",
"USER": "Participant"
},
"EXCHANGES": {
"TITLE": "Échanges Paramètres",
"DESCRIPTION": "Description des Échanges",
"INSTRUCTIONS": "Instructions du Chatbot",
"CUE": "Initial Cue",
"ASSISTANT": "Assistant",
"CREATE_ASSISTANT": "Veuillez créer au moins un assistant.",
"FOLLOW_UP_QUESTIONS": "Nombre de Questions de Suivi",
"ON_COMPLETE": "Instruction sur l'achèvement de l'échange",
"ON_COMPLETE_HELPER": "Ce texte s'affichera une fois que le nombre donné de questions de suivi aura été répondu. Laisser en blanc si aucun message n'est affiché.",
"DISABLE_HARD_LIMIT": "Rejet Automatique",
"HARD_LIMIT_INFO": "Si cette case est cochée, l'échange suivant commencera automatiquement une fois que le nombre de questions de suivi sera atteint",
"CREATE": "Veuillez créer au moins un échange."
}
},
"CONVERSATIONS": {
"TITLE": "Voir les Conversations",
"MEMBER": "Veuillez sélectionner un membre",
"PLACEHOLDER": "Veuillez sélectionner un membre",
"NONE": "Aucune conversation jusqu'à présent.",
"COMPLETE": "Terminé",
"INCOMPLETE": "Pas terminé",
"RESET": "Supprimer et réinitialiser la conversation"
},
"START": "Démarrer",
"MESSAGE_BOX": {
"INSERT_HERE": "Votre réponse ici...",
"SEND": "Envoyer",
"DONE": "Fini"
}
}
}
Loading

0 comments on commit e138776

Please sign in to comment.