-
Notifications
You must be signed in to change notification settings - Fork 44.5k
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
feat(agent): Introduce Python code execution as prompt strategy #7142
Conversation
✅ Deploy Preview for auto-gpt-docs canceled.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7142 +/- ##
==========================================
- Coverage 53.79% 53.43% -0.36%
==========================================
Files 124 127 +3
Lines 7027 7293 +266
Branches 911 967 +56
==========================================
+ Hits 3780 3897 +117
- Misses 3114 3258 +144
- Partials 133 138 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Should this be in forge?? |
CI Failure Feedback 🧐(Checks updated until commit e204491)
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:
where Configuration options
See more information about the |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
from .base import BaseAgent, BaseAgentActionProposal | ||
from .prompt_strategies.one_shot import OneShotAgentActionProposal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OneShotAgentActionProposal is not part of .agent
@@ -97,19 +103,20 @@ def __init__( | |||
llm_provider: ChatModelProvider, | |||
file_storage: FileStorage, | |||
legacy_config: Config, | |||
prompt_strategy_class: type[PromptStrategy] = CodeFlowAgentPromptStrategy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decouple agent.py & OneShot. pass this class for custom prompt strategy
if not parsed_response.python_code: | ||
raise ValueError("python_code is empty") | ||
|
||
available_functions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for the generated code validation.
autogpts/autogpt/autogpt/app/cli.py
Outdated
@@ -2,18 +2,21 @@ | |||
from logging import _nameToLevel as logLevelMap | |||
from pathlib import Path | |||
from typing import Optional | |||
from dotenv import load_dotenv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this, for debugging purpose, will revert
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CodeFlowExecutionComponent(CommandProvider): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... BaseAgentActionProposal use use_tool
which only executes a single tool, and it's already intertwined with the agent implementation. So my approach on having this code flow execution is by returning BaseAgentActionProposal
that use this newly created tool, which is basically executing python code using already existing other tools as variables.
@@ -158,6 +159,37 @@ def fmt_line(self) -> str: | |||
) | |||
return f"{self.name}: {self.description}. Params: ({params})" | |||
|
|||
def fmt_header(self, callable=None) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callable part here is unused, will revert
@@ -443,6 +443,8 @@ async def create_chat_completion( | |||
if not parse_errors: | |||
try: | |||
parsed_result = completion_parser(assistant_msg) | |||
if isinstance(parsed_result, Coroutine): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So completion_parser
needs to be async for the code validation, I did this instead of changing the whole usage of it to async.
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
- Amend `main.py:update_user(..)` to improve displaying of existing + new prompt strategy output - Replace `"execute_code_flow"` literals with references to the command definition
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
Do we have a status on this? |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
@majdyz can I close this PR, seems we're not working on it? |
This could be a really awesome block |
@aarushik93 sure I'll close it. |
Background
Add support for executing agent steps by running Python code. This allows for more complicated composite function calls within each step of agent execution.
Related:
Changes 🏗️
PromptStrategy
:CodeFlowAgentPromptStrategy
undercode_flow.py
utils.function
package that handle a python code validation that utilizeruff
&pyRight
as the validation engines.CodeFlowAgentPromptStrategy
as the existing default strategy.PR Quality Scorecard ✨
+2 pts
+5 pts
+5 pts
+5 pts
-4 pts
+4 pts
+5 pts
-5 pts
agbenchmark
to verify that these changes do not regress performance?+10 pts