Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add export functionality (#4) #65

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading