From 3322c8f52f899663641eb1855c63cfa02a55653c Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Wed, 16 Aug 2023 11:36:47 +0200 Subject: [PATCH] Added callback to ask_for_human_intervention --- euclid/helpers/Project.py | 5 ++++- euclid/helpers/agents/Developer.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/euclid/helpers/Project.py b/euclid/helpers/Project.py index 9f3343a..080ef0d 100644 --- a/euclid/helpers/Project.py +++ b/euclid/helpers/Project.py @@ -170,7 +170,7 @@ class Project: delete_unconnected_steps_from(self.checkpoints['last_command_run'], 'previous_step') delete_unconnected_steps_from(self.checkpoints['last_user_input'], 'previous_step') - def ask_for_human_intervention(self, message, description=None): + def ask_for_human_intervention(self, message, description=None, cbs={}): print(colored(message, "yellow")) if description is not None: print(description) @@ -181,6 +181,9 @@ class Project: 'Once you are ready, type "continue" to continue.', ) + if answer in cbs: + return cbs[answer]() + if answer != '' and answer != 'continue': confirmation = styled_text( self, diff --git a/euclid/helpers/agents/Developer.py b/euclid/helpers/agents/Developer.py index 204083f..b5f5360 100644 --- a/euclid/helpers/agents/Developer.py +++ b/euclid/helpers/agents/Developer.py @@ -120,7 +120,9 @@ class Developer(Agent): def continue_development(self): while True: - user_feedback = self.project.ask_for_human_intervention('Can you check if all this works?') + user_feedback = self.project.ask_for_human_intervention( + 'Can you check if all this works? If you want to run the app, just type "r" and press ENTER', + cbs={ 'r': lambda: run_command_until_success(self.run_command, None, iteration_convo, force=True) }) if user_feedback == 'DONE': return True