Skip to content

Commit 70b2784

Browse files
Improved flow
1 parent cac93fe commit 70b2784

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

interaction.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ class ChatWindow {
169169
return this.#messages;
170170
}
171171

172+
clearMessages() {
173+
this.#messages = [];
174+
}
175+
172176
async sendUserMessage(prompt) {
173177
let userMessage = this.#makeMessage(this.#USER, prompt);
174178
this.#messagesAppend(userMessage);
@@ -211,9 +215,12 @@ textInputBox.addEventListener('keydown', async function (e) {
211215

212216

213217
if (chatWindow.getState() == CHAT_WINDOW_STATES.CREATE) {
214-
constructedPrompt = `Given the following current date and time: ${day}, ${today}T${time}:00 and planning prompt: '${planning_prompt}', format the prompt's contents as JSON objects with the following keys: summary, description, start, end, in an array that can be parsed to create calendar events. Please use 1-2 emojis per complex sentence in the title's lhs and description to make them more personal.`;
218+
constructedPrompt = `Given the following current date and time: ${day}, ${today}T${time}:00 and planning prompt: '${planning_prompt}', format the prompt's contents as JSON objects with the following keys: summary, description, start, end (don't write timezone.), in an array that can be parsed to create calendar events. Please use 1-2 emojis per complex sentence in the title's lhs and description to make them more personal.`;
215219
chatWindow.setState(CHAT_WINDOW_STATES.SPECIFY);
216-
chatWindow.sendUserMessage(constructedPrompt);
220+
await chatWindow.sendUserMessage(constructedPrompt);
221+
(async () => {
222+
await chatWindow.sendSystemMessage("Is this event ok, then write \"yes\" to confirm.");
223+
})();
217224
} else {
218225
if (constructedPrompt == "yes") {
219226
let messages = chatWindow.getMessages()
@@ -228,6 +235,13 @@ textInputBox.addEventListener('keydown', async function (e) {
228235
(async () => {
229236
await chatWindow.sendSystemMessage("Event creation attempted!");
230237
})();
238+
chatWindow.setState(CHAT_WINDOW_STATES.CREATE);
239+
chatWindow.clearMessages
240+
} else {
241+
await chatWindow.sendUserMessage(constructedPrompt);
242+
(async () => {
243+
await chatWindow.sendSystemMessage("Is this event ok, then write \"yes\" to confirm.");
244+
})();
231245
}
232246
}
233247
}

0 commit comments

Comments
 (0)