yoheinakajima / babyagi

https://babyagi.org/
20.36k stars 2.67k forks source link

Stop code and give human feedback #161

Closed juanfradb closed 1 month ago

juanfradb commented 1 year ago

It will be great if with a command or keyboard I can stop babyagi and provide some feedback

Hoodie2389 commented 1 year ago

yah. And it just keeps running and runnning. Where does it end and how does it summarize all the findings up?

DonTido commented 1 year ago

Add the following code to your babyagi.py file. It will turn the continuous mode off and prompt you at the end of each task to modify the task, proceed, or exit.

Add user interactions to the task list

def user_interaction():
    while True:
        print("\033[96m\033[1m" + "\n*****USER INPUT*****\n" + "\033[0m\033[0m")
        print("Select an option:")
        print("1. Modify tasks")
        print("2. Proceed")
        print("3. Stop and exit")
        user_input = input("Enter the number corresponding to your choice: ")

        if user_input == "1":
            return "modify_tasks"
        elif user_input == "2":
            return "proceed"
        elif user_input == "3":
            return "stop"
        else:
            print("Invalid input. Please enter a valid number.")
Hoodie2389 commented 1 year ago

where do we put user_interaction() to use in the main code?

DonTido commented 1 year ago

Add it before the Main Loop.

Screenshot 2023-04-19 at 8 28 03 AM
DonTido commented 1 year ago

I forgot to mention to add the following section. You will also need to add the following code to the end of the Main Loop.

Step 6: User interaction

    user_choice = user_interaction()
    if user_choice == "modify_tasks":
        new_task_name = input("Enter the new task to be added: ")
        new_task = {
            "task_id": tasks_storage.next_task_id(),
            "task_name": new_task_name
        }
        tasks_storage.append(new_task)
        prioritization_agent()
    elif user_choice == "stop":
        break

The whole last section should look like this.

Screenshot 2023-04-19 at 9 15 24 AM
AllyourBaseBelongToUs commented 5 months ago

Something akin to a "Pause" Button would be appreciated