From 9aa1ea697b2523e9ceea38315512caafa18a4c2a Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Tue, 1 Aug 2023 17:20:16 +0200 Subject: [PATCH] Updated function for setting up the convo in playground --- euclid/const/convert_to_playground_convo.js | 15 ++++++++++++++- euclid/helpers/AgentConvo.py | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/euclid/const/convert_to_playground_convo.js b/euclid/const/convert_to_playground_convo.js index 2fa1b09..7b4c97a 100644 --- a/euclid/const/convert_to_playground_convo.js +++ b/euclid/const/convert_to_playground_convo.js @@ -9,13 +9,26 @@ async function fill_playground(messages) { if (system_messages.length > 0) { let system_message_textarea = document.querySelector('.chat-pg-instructions').querySelector('textarea'); system_message_textarea.focus(); + system_message_textarea.value = ''; document.execCommand("insertText", false, system_messages[0].content); await sleep(100); } + // Remove all previous messages + let remove_buttons = document.querySelectorAll('.chat-message-remove-button'); + for (let j = 0; j < 10; j++) { + for (let i = 0; i < remove_buttons.length; i++) { + let clickEvent = new Event('click', { + 'bubbles': true, + 'cancelable': true + }); + remove_buttons[i].dispatchEvent(clickEvent); + } + } + let other_messages = messages.filter(msg => msg.role !== 'system'); - for (let i = 0; i < other_messages.length - 1; i++) { + for (let i = 0; i < other_messages.length; i++) { document.querySelector('.add-message').click() await sleep(100); } diff --git a/euclid/helpers/AgentConvo.py b/euclid/helpers/AgentConvo.py index 781b63d..1a6cc40 100644 --- a/euclid/helpers/AgentConvo.py +++ b/euclid/helpers/AgentConvo.py @@ -73,7 +73,7 @@ class AgentConvo: print(f"{content}\n") logger.info(f"{print_msg}: {content}\n") - def to_playground(self, path): + def to_playground(self): with open('const/convert_to_playground_convo.js', 'r', encoding='utf-8') as file: content = file.read() process = subprocess.Popen('pbcopy', stdin=subprocess.PIPE)