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

More control over flow ( interrupt command JIT + choose commands to ignore/stop on + stop when looping ) #3914

Closed

Conversation

eyalk11
Copy link
Contributor

@eyalk11 eyalk11 commented May 6, 2023

Background

Now it is quite challenging to control the flow. You would need to assume the next N authorised commands are OK, beforehand. If it goes astray, you have nothing to do, but to wait after the batch.
This commit make it possible to interrupt just in time and define commands that are more and less relevant with regard to batch.

Changes

  1. Added config.commands_to_stop and config.commands_to_ignore.

config.commands_to_stop would stop after the command anyway. For example, you might want to stop on task completion, anyway.

config.commands_to_ignore are commands that authorized automatically and don't increase the counter.

  1. Changed spinner class to allow for interruption
  • <space> in the middle of thinking means soft-interrupt complete execution and ask for user input after execution).
  • <q> means abort - exit task immediately and ask for user input.

Have two implementation for linux and windows.

Introduced a function async_task_and_spin to wait for either task completion or interrupt.

  1. Stop if already executed a command

To do so, it keeps all previously executed commands in set.

Documentation

In code

Test Plan

I just checked the code on my own, saw that both soft and hard interrupts working.
commands_to_stop and to_ignore seems to be working.
There was an error in test_memory_trimmed_from_context that seem unrelated.

    memory_found = memory.get_relevant("Important Information", 5)
    assert memory_found[0] == expected_permanent_memory

Want to see if it fails on workflow.

PR Quality Checklist

  • My pull request is atomic and focuses on a single change. (Arguably, you could split this into adding ignore/to stop and adding spinner. But it is part of whole. )
  • I have thoroughly tested my changes with multiple different prompts.
  • I have considered potential risks and mitigations for my changes.
  • I have documented my changes clearly and comprehensively.
  • I have not snuck in any "extra" small tweaks changes

I didn't add tests because of lack of time. A bit of help is wanted, if you think testing is required for it.

This is how soft interrupt looks like. It keeps thinking afterwards.
image

@vercel
Copy link

vercel bot commented May 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) May 6, 2023 4:48pm

@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2023

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size

@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2023

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size

@eyalk11 eyalk11 changed the title Interrupt commands Interrupt commands (control flow by interrupting commands JIT or choose commands to ignore/stop on) May 6, 2023
@eyalk11 eyalk11 force-pushed the interrupt_commands branch from b495d65 to 105ecce Compare May 6, 2023 16:48
@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2023

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size

@eyalk11 eyalk11 mentioned this pull request May 6, 2023
1 task
@eyalk11 eyalk11 changed the title Interrupt commands (control flow by interrupting commands JIT or choose commands to ignore/stop on) More control over flow ( interrupt command JIT + choose commands to ignore/stop on + stop when looping ) May 7, 2023
@Boostrix Boostrix mentioned this pull request May 7, 2023
5 tasks
@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label May 13, 2023
@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@k-boikov k-boikov added the enhancement New feature or request label May 14, 2023
@Pwuts
Copy link
Member

Pwuts commented Jun 14, 2023

This looks interesting, and like a significant potential UX improvement

@Pwuts Pwuts added this to the v0.4.2 Release milestone Jun 14, 2023
@lc0rp
Copy link
Contributor

lc0rp commented Jun 23, 2023

@eyalk11 We're prepping for release v0.4.3. Please resolve conflicts and stand by as we merge.

@Pwuts Pwuts modified the milestones: v0.4.3 Release, v0.4.4 Release Jun 23, 2023
@eyalk11
Copy link
Contributor Author

eyalk11 commented Jun 27, 2023

OK, I am working on this. it is a bit hard to merge. (merge_int branch in my fork).

@eyalk11 eyalk11 force-pushed the interrupt_commands branch from 105ecce to 4827736 Compare June 28, 2023 01:18
@netlify
Copy link

netlify bot commented Jun 28, 2023

Deploy Preview for auto-gpt-docs failed.

Name Link
🔨 Latest commit 24ad3dd
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/64ce9132ccb7610008235587

@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Jun 28, 2023
@github-actions
Copy link
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@github-actions github-actions bot added size/l and removed size/xl labels Jun 28, 2023
@eyalk11
Copy link
Contributor Author

eyalk11 commented Jun 28, 2023

(There are still some merging issues, will solve)

@codecov
Copy link

codecov bot commented Jun 28, 2023

Codecov Report

Patch coverage: 59.01% and project coverage change: +0.01% 🎉

Comparison is base (3a2d08f) 51.93% compared to head (24ad3dd) 51.94%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3914      +/-   ##
==========================================
+ Coverage   51.93%   51.94%   +0.01%     
==========================================
  Files         117      117              
  Lines        4987     5088     +101     
  Branches      671      694      +23     
==========================================
+ Hits         2590     2643      +53     
- Misses       2199     2235      +36     
- Partials      198      210      +12     
Files Changed Coverage Δ
autogpt/app/spinner.py 65.62% <55.55%> (-31.75%) ⬇️
autogpt/app/main.py 45.97% <61.70%> (+2.53%) ⬆️
autogpt/config/config.py 79.88% <100.00%> (+0.34%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eyalk11 eyalk11 force-pushed the interrupt_commands branch 3 times, most recently from 87d0158 to 592514b Compare July 14, 2023 18:47
@eyalk11
Copy link
Contributor Author

eyalk11 commented Jul 14, 2023

I added test for command_to_stop/ignore.

@eyalk11 eyalk11 force-pushed the interrupt_commands branch 2 times, most recently from 1827465 to f8032a8 Compare July 14, 2023 19:16
requirements.txt Outdated
@@ -29,6 +29,7 @@ spacy>=3.0.0,<4.0.0
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl
prompt_toolkit>=3.0.38
pydantic
frozendict

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keyboard not in req file because isn't supported on mac.

if (
pressed_key
and pressed_key == key_to_check
or (os.name == "nt" and keyboard.is_pressed(keyboard_key))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will work if out of focus

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Jul 20, 2023
@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@lc0rp lc0rp added this to the v0.4.7 Release milestone Jul 22, 2023
@lc0rp
Copy link
Contributor

lc0rp commented Jul 22, 2023

@eyalk11 The agent was updated recently, probably the reason for the conflicts.

@lc0rp lc0rp modified the milestones: v0.4.7 Release, v0.4.8 Aug 1, 2023
@eyalk11 eyalk11 force-pushed the interrupt_commands branch from f8032a8 to e028f9f Compare August 5, 2023 00:49
@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Aug 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2023

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@eyalk11 eyalk11 force-pushed the interrupt_commands branch 3 times, most recently from aadef76 to ce6ad6d Compare August 5, 2023 16:49
@eyalk11 eyalk11 force-pushed the interrupt_commands branch from ce6ad6d to 24ad3dd Compare August 5, 2023 18:13
@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Aug 19, 2023
@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflicts Automatically applied to PRs with merge conflicts enhancement New feature or request needs restructuring PRs that should be split or restructured size/l
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants