Skip to content

Commit

Permalink
feat: add export functionality (#4) (#65)
Browse files Browse the repository at this point in the history
* feat: add option in chat settings to send complete message history to chatbot

* feat: add export functionality for exporting conversations

* feat: add interaction and exchange names

* feat: export id instead of name for debugging purposes

---------

Co-authored-by: deRohrer <[email protected]>
  • Loading branch information
juancarlosfarah and deRohrer authored Sep 4, 2024
1 parent 42e9bb9 commit e1a0411
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 134 deletions.
3 changes: 3 additions & 0 deletions src/config/appSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ export type AssistantsSettingsType = {
};

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

export type ExchangeSettings = {
id: UUID;
name: string;
assistant: AssistantSettings;
description: string;
chatbotInstructions: string;
Expand Down
9 changes: 7 additions & 2 deletions src/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
},
"CHAT": {
"TITLE": "Chat Settings",
"NAME": "Interaction Name",
"DESCRIPTION": "Chat Description",
"INSTRUCTIONS": "Participant Instructions",
"END": "End Screen Text",
"USER": "Participant"
"SEND_ALL": "Let Assistant Remember All Messages",
"SEND_ALL_INFO": "If checked, all previous messages will be included in the prompt sent to the chatbot, instead of only messages from the current exchange."
},
"EXCHANGES": {
"TITLE": "Exchanges Settings",
"NAME": "Exchange Name",
"DESCRIPTION": "Exchanges Description",
"INSTRUCTIONS": "Chatbot instructions",
"CUE": "Initial Cue",
Expand All @@ -54,14 +57,16 @@
},
"CONVERSATIONS": {
"TITLE": "View Conversations",
"EXPORT_ALL": "Export All",
"TABLE": {
"MEMBER": "Member",
"UPDATED": "Last change",
"STATUS": "Status",
"NOT_STARTED": "Not started",
"COMPLETE": "Completed",
"INCOMPLETE": "Not completed",
"DELETE": "Delete interaction",
"DELETE": "Delete",
"EXPORT": "Export",
"NONE": "No conversations so far."
},
"RESET": "Delete and reset conversation"
Expand Down
9 changes: 7 additions & 2 deletions src/langs/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
},
"CHAT": {
"TITLE": " Paramètres du Chat",
"NAME": "Nom de l'Interaction",
"DESCRIPTION": "Description du Chat",
"INSTRUCTIONS": "Instructions pour le Participant",
"END": "Texte de Fin d'Écran",
"USER": "Participant"
"SEND_ALL": "Laissez l'Assistant se Souvenir de Tous les Messages",
"SEND_ALL_INFO": "Si cette option est cochée, tous les messages précédents seront inclus dans l'invite envoyée au chatbot, au lieu des seuls messages de l'échange en cours. "
},
"EXCHANGES": {
"TITLE": "Échanges Paramètres",
"NAME": "Nom de l'Échange",
"DESCRIPTION": "Description des Échanges",
"INSTRUCTIONS": "Instructions du Chatbot",
"CUE": "Initial Cue",
Expand All @@ -54,14 +57,16 @@
},
"CONVERSATIONS": {
"TITLE": "Voir les Conversations",
"EXPORT_ALL": "Exporter Tout",
"TABLE": {
"MEMBER": "Membre",
"UPDATED": "Dernière modification",
"STATUS": "Statut",
"NOT_STARTED": "Non démarré",
"COMPLETE": "Completed",
"INCOMPLETE": "Non terminé",
"DELETE": "Supprimer l'interaction",
"DELETE": "Supprimer",
"EXPORT": "Exporter",
"NONE": "Aucune conversation jusqu'à présent"
},
"RESET": "Supprimer et réinitialiser la conversation"
Expand Down
3 changes: 3 additions & 0 deletions src/modules/context/SettingsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ export const defaultSettingsValues: AllSettingsType = {
assistantList: [{ id: uuidv4(), name: '', description: '' }],
},
chat: {
name: '',
description: '',
participantInstructions: '',
participantEndText: '',
sendAllToChatbot: false,
},
exchanges: {
exchangeList: [
{
id: uuidv4(),
name: '',
assistant: {
id: '',
name: '',
Expand Down
1 change: 1 addition & 0 deletions src/modules/interaction/ParticipantInteraction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ const ParticipantInteraction = (): ReactElement => {
return [];
})}
participant={currentMember}
sendAllMessages={interaction.sendAllToChatbot}
/>
);
};
Expand Down
12 changes: 11 additions & 1 deletion src/modules/message/MessagesPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type MessagesPaneProps = {
participant: Agent;
autoDismiss: boolean;
goToNextExchange: () => void;
sendAllMessages?: boolean;
readOnly?: boolean;
};

Expand All @@ -51,6 +52,7 @@ const MessagesPane = ({
participant,
autoDismiss,
goToNextExchange,
sendAllMessages = false,
readOnly = false,
}: MessagesPaneProps): ReactElement => {
// Hook to post chat messages asynchronously using mutation
Expand Down Expand Up @@ -103,6 +105,7 @@ const MessagesPane = ({
id: uuidv4(),
content: currentExchange.participantCue,
sender: currentExchange.assistant,
sentAt: new Date(),
},
]);
}
Expand Down Expand Up @@ -145,7 +148,12 @@ const MessagesPane = ({
*/
function handlePostChatbot(newMessage: Message): void {
// Build the prompt for the chatbot using the existing messages and the new message
const prompt: ChatBotMessage[] = [...buildPrompt(msgs, newMessage)];
const prompt: ChatBotMessage[] = [
...buildPrompt(
[...(sendAllMessages ? pastMessages : []), ...msgs],
newMessage,
),
];

// Send the prompt to the chatbot API and handle the response
postChatBot(prompt)
Expand All @@ -154,6 +162,7 @@ const MessagesPane = ({
id: uuidv4(),
content: chatBotRes.completion,
sender: currentExchange.assistant,
sentAt: new Date(),
};

// Add the chatbot's response to the list of messages
Expand All @@ -174,6 +183,7 @@ const MessagesPane = ({
id: uuidv4(),
content,
sender: participant,
sentAt: new Date(),
};

// Update the messages state with the new message
Expand Down
Loading

0 comments on commit e1a0411

Please sign in to comment.