AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

Use `async`/`await` where applicable

Open Androbin opened this issue 1 year ago β€’ 50 comments

Background

Needed for #386 @itaim Needed for #1139 @merwanehamadi Needed for #1937 @arrenv Needed for #1243 Needed for #2442 @SwiftyTheCoder

Changes

Use async/await where applicable, change openai.{ChatCompletion,Embedding}.create to .acreate

Documentation

Test Plan

PR Quality Checklist

  • [x] My pull request is atomic and focuses on a single change.
  • [x] I have thoroughly tested my changes with multiple different prompts.
  • [x] I have considered potential risks and mitigations for my changes.
  • [x] I have documented my changes clearly and comprehensively.
  • [x] I have not snuck in any "extra" small tweaks changes

Androbin avatar Apr 14 '23 05:04 Androbin

Sounds great, I think it will also fix my issue where agents start talking asynchronously for some reason. I hear them talking word for word in a very weird and gibberish way

Wladastic avatar Apr 14 '23 10:04 Wladastic

@Androbin There are conflicts now

nponeccop avatar Apr 15 '23 14:04 nponeccop

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

github-actions[bot] avatar Apr 17 '23 17:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 17 '23 18:04 github-actions[bot]

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

github-actions[bot] avatar Apr 17 '23 19:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 17 '23 19:04 github-actions[bot]

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

github-actions[bot] avatar Apr 17 '23 22:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 17 '23 22:04 github-actions[bot]

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

github-actions[bot] avatar Apr 18 '23 14:04 github-actions[bot]

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

github-actions[bot] avatar Apr 18 '23 14:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 18 '23 17:04 github-actions[bot]

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

github-actions[bot] avatar Apr 19 '23 00:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 19 '23 00:04 github-actions[bot]

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

github-actions[bot] avatar Apr 19 '23 00:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 19 '23 01:04 github-actions[bot]

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

github-actions[bot] avatar Apr 19 '23 21:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 19 '23 22:04 github-actions[bot]

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

github-actions[bot] avatar Apr 19 '23 23:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 20 '23 04:04 github-actions[bot]

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

github-actions[bot] avatar Apr 21 '23 02:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 21 '23 21:04 github-actions[bot]

Coverage report

The coverage rate went from 31.23% to 31.2% :arrow_down: The branch rate is 17%.

34.78% of new lines are covered.

Diff Coverage details (click to unfold)

autogpt/commands/improve_code.py

0% of new lines are covered (0% of the complete file). Missing lines: 14, 35

autogpt/commands/image_gen.py

50% of new lines are covered (21.42% of the complete file). Missing lines: 32, 101

autogpt/memory/milvus.py

0% of new lines are covered (2.7% of the complete file). Missing lines: 42, 51, 59, 64, 86, 97

autogpt/commands/analyze_code.py

0% of new lines are covered (0% of the complete file). Missing lines: 13, 31

autogpt/processing/text.py

20% of new lines are covered (17.07% of the complete file). Missing lines: 112, 120, 131, 138

autogpt/json_utils/json_fix_llm.py

54.54% of new lines are covered (33.62% of the complete file). Missing lines: 65, 96, 98, 179, 220

autogpt/memory/base.py

57.14% of new lines are covered (57.14% of the complete file). Missing lines: 14, 19, 22

autogpt/commands/web_selenium.py

0% of new lines are covered (0% of the complete file). Missing lines: 34, 46

autogpt/app.py

36.36% of new lines are covered (21.01% of the complete file). Missing lines: 110, 111, 113, 155, 206, 212, 222

autogpt/main.py

0% of new lines are covered (0% of the complete file). Missing lines: 2, 7

autogpt/agent/agent_manager.py

50% of new lines are covered (12.84% of the complete file). Missing lines: 42, 96

autogpt/commands/write_tests.py

0% of new lines are covered (0% of the complete file). Missing lines: 15, 37

autogpt/memory/redismem.py

50% of new lines are covered (26.76% of the complete file). Missing lines: 91, 113, 133

autogpt/memory/weaviate.py

0% of new lines are covered (2.59% of the complete file). Missing lines: 73, 74, 89, 90, 102, 103

autogpt/logs.py

33.33% of new lines are covered (33.33% of the complete file). Missing lines: 215, 222

autogpt/commands/file_operations.py

50% of new lines are covered (16.93% of the complete file). Missing lines: 133

autogpt/agent/agent.py

20% of new lines are covered (8.9% of the complete file). Missing lines: 86, 95, 194, 215

autogpt/memory/local.py

50% of new lines are covered (42.25% of the complete file). Missing lines: 76, 111, 124

autogpt/memory/no_memory.py

100% of new lines are covered (62.5% of the complete file).

autogpt/memory/pinecone.py

50% of new lines are covered (25% of the complete file). Missing lines: 47, 55, 67

autogpt/chat.py

50% of new lines are covered (19.78% of the complete file). Missing lines: 182, 198

autogpt/llm_utils.py

33.33% of new lines are covered (11.53% of the complete file). Missing lines: 52, 100, 108, 136, 164, 171, 174, 187

autogpt/cli.py

0% of new lines are covered (0% of the complete file). Missing lines: 2, 53, 179, 183

github-actions[bot] avatar Apr 21 '23 21:04 github-actions[bot]

@Pwuts PTAL

Androbin avatar Apr 22 '23 14:04 Androbin

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

github-actions[bot] avatar Apr 22 '23 21:04 github-actions[bot]

Can we put a pin in this one? There's another async PR that I'd prefer to have merged.

https://github.com/Significant-Gravitas/Auto-GPT/pull/2442

Sorry, super-awkward when this happens. I've put a wontfix label on this one for now.

Team is working on a mechanism whereby PRs need to be created as an issue that then is referenced by the PR, so we can avoid dups.

If there's a reason for promoting THIS PR, please do say!

p-i- avatar Apr 23 '23 02:04 p-i-

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 23 '23 05:04 github-actions[bot]

Codecov Report

Patch coverage: 34.78% and project coverage change: -7.50 :warning:

Comparison is base (2b5852f) 45.09% compared to head (7744460) 37.60%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1245      +/-   ##
==========================================
- Coverage   45.09%   37.60%   -7.50%     
==========================================
  Files          60       60              
  Lines        2856     2864       +8     
  Branches      472      473       +1     
==========================================
- Hits         1288     1077     -211     
- Misses       1463     1725     +262     
+ Partials      105       62      -43     
Impacted Files Coverage Ξ”
autogpt/__main__.py 0.00% <0.00%> (ΓΈ)
autogpt/cli.py 0.00% <0.00%> (ΓΈ)
autogpt/commands/analyze_code.py 0.00% <0.00%> (ΓΈ)
autogpt/commands/improve_code.py 0.00% <0.00%> (ΓΈ)
autogpt/commands/web_selenium.py 0.00% <0.00%> (ΓΈ)
autogpt/commands/write_tests.py 0.00% <0.00%> (ΓΈ)
autogpt/memory/milvus.py 3.03% <0.00%> (ΓΈ)
autogpt/memory/weaviate.py 3.27% <0.00%> (ΓΈ)
autogpt/agent/agent.py 12.74% <20.00%> (-28.44%) :arrow_down:
autogpt/processing/text.py 21.87% <20.00%> (ΓΈ)
... and 13 more

... and 8 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Apr 23 '23 05:04 codecov[bot]

@p-i- I don't see how this PR conflicts with #2442. It does not change any structure, all it does is replace .create with .acreate and propagate async and await through the caller hierarchy. Any PR seeking to introduce async code has to do exactly that. If #2442 ends up reimplementing some of these functions, it still needs to add async and await everywhere else.

Androbin avatar Apr 23 '23 05:04 Androbin

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

github-actions[bot] avatar Apr 23 '23 19:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 26 '23 02:04 github-actions[bot]