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

refactor(agent, forge): Move library code from autogpt to forge #7106

Conversation

kcze
Copy link
Contributor

@kcze kcze commented Apr 25, 2024

Background

The goal of this PR is to move reusable code (including components) to forge so AutoGPT agent is built using forge.

Changes 🏗️

Modules moved from autogpt to forge:

original location moved to
autogpt.agents.base
autogpt.agents.components
autogpt.agents.protocols
forge.agent.base
forge.agent.components
forge.agent.protocols
autogpt.models.command
autogpt.command_decorator
autogpt.models.command_parameter
forge.command.command
forge.command.decorator
forge.command.parameter
autogpt.commands
autogpt.components
autogpt.agents.features
forge.components { .action_history, .code_executor, .context, .file_manager, .git_operations, .image_gen, .system, .user_interaction, .watchdog, .web.search, .web.selenium }
autogpt.config forge.config { .config, .ai_profile, .ai_directives }
autogpt.processing forge.content_processing { .html, .text }
autogpt.file_storage forge.file_storage { .base, .gcs, .local, .s3 }
autogpt.core.utils.json_utils forge.json.parsing
autogpt.core.prompting.base
autogpt.core.prompting.schema
forge.llm.prompting.base
forge.llm.prompting.schema
autogpt.prompts.utils forge.llm.prompting.utils
autogpt.core.resource.model_providers forge.llm.providers { .anthropic, .multi, .openai }
autogpt.llm.providers.openai
autogpt.core.resource.model_providers.utils
forge.llm.providers.utils
autogpt.logs forge.logging { .config, .filters, .formatters, .handlers, .helpers, .utils }
autogpt.models.action_history:Action*
autogpt.core.configuration.schema
autogpt.core.utils.json_schema
autogpt.core.resource.schema
autogpt.models.utils
forge.models.action
forge.models.config
forge.models.json_schema
forge.models.providers
forge.models.utils
autogpt.speech forge.speech { .base, .say, .eleven_labs, .gtts, .macos_tts, .stream_elements_speech }
autogpt.utils.exceptions
autogpt.utils.file_operations_utils
autogpt.url_utils.validators
autogpt.utils.utils
forge.utils.exceptions
forge.utils.file_operations
forge.utils.url_validator
forge.utils.const
forge.utils.yaml_validator
docs/content/AutoGPT/components/ docs/content/forge/components/

The rest are mostly import updates, and some sporadic removals and necessary updates (for example to fix circular deps):

  • Changed CommandOutput = Any to remove coupling with ContextItem (no longer needed)
  • Removed unused Singleton class
  • Reluctantly moved speech to forge due to coupling (tts needs to be changed into component)
  • Moved function_specs_from_commands and core/resource/model_providers to llm/providers (resources were a core thing and are no longer relevant)
  • Keep tests in autogpt to reduce changes in this PR
  • Removed unused memory-related code from tests
  • Removed duplicated classes: FancyConsoleFormatter, BelowLevelFilter
  • prompt_settings.yaml is in both autogpt and forge because for some reason doesn't work when placed in just one dir (need to be taken care of)
  • Removed config param from clean_input, it wasn't used and caused circular dependency
  • Renamed BaseAgentActionProposal to ActionProposal
  • Updated pyproject.toml in forge and autogpt
  • Moved Action* models from forge/components/action_history/model.py to forge/models/action.py as those are relevant to the entire agent and not just EventHistoryComponent + to reduce coupling
  • Renamed DEFAULT_ASK_COMMAND to ASK_COMMAND and DEFAULT_FINISH_COMMAND to FINISH_COMMAND
  • Renamed AutoGptFormatter to ForgeFormatter and moved to forge
  • Includes feat(agent): Update component ordering #7148

PR Quality Scorecard ✨

  • Have you used the PR description template?   +2 pts
  • Is your pull request atomic, focusing on a single change?   +5 pts
  • Have you linked the GitHub issue(s) that this PR addresses?   +5 pts
  • Have you documented your changes clearly and comprehensively?   +5 pts
  • Have you changed or added a feature?   -4 pts
    • Have you added/updated corresponding documentation?   +4 pts
    • Have you added/updated corresponding integration tests?   +5 pts
  • Have you changed the behavior of AutoGPT?   -5 pts
    • Have you also run agbenchmark to verify that these changes do not regress performance?   +10 pts

PR Type

enhancement, bug_fix


Description

  • Introduced new configuration management classes in forge/config/schema.py to enhance system and user settings management.
  • Developed a new user input utility function in forge/utils/input.py to streamline input handling and improve error management.
  • Initialized the event_history module in forge/components/event_history/__init__.py to better organize event-related classes and functions.
  • Updated the LLM providers initialization in forge/llm/providers/__init__.py to include a new utility function, enhancing command specifications handling.
  • Enhanced the logging system by integrating new filters and formatters in forge/logging/__init__.py.
  • Fixed incorrect imports in the SDK initialization file forge/sdk/__init__.py, removing references to a non-existent errors module and adding necessary exception handling utilities.

Changes walkthrough 📝

Relevant files
Enhancement
schema.py
Add Configuration Management Classes                                         

autogpts/forge/forge/config/schema.py

  • Added new classes SystemConfiguration, SystemSettings, and
    UserConfigurable for configuration management.
  • These classes support the configuration of system-wide settings and
    user-specific settings.
  • +352/-1 
    input.py
    Implement User Input Handling Utility                                       

    autogpts/forge/forge/utils/input.py

  • Added a new utility function clean_input to handle user input with
    error handling for keyboard interrupts.
  • +19/-0   
    __init__.py
    Update LLM Providers Initialization                                           

    autogpts/forge/forge/llm/providers/init.py

  • Updated imports to include new utility function
    function_specs_from_commands.
  • +2/-0     
    __init__.py
    Enhance Logging Initialization with New Components             

    autogpts/forge/forge/logging/init.py

    • Added imports for new logging filters and formatters.
    +2/-13   
    Configuration changes
    __init__.py
    Initialize Event History Module                                                   

    autogpts/forge/forge/components/event_history/init.py

  • Created an initialization file for the event_history module to manage
    action proposals and results.
  • +10/-0   
    Bug_fix
    __init__.py
    Correct SDK Initialization Imports                                             

    autogpts/forge/forge/sdk/init.py

  • Removed erroneous import of deleted module errors.
  • Added import for exception handling utilities.
  • +2/-2     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @github-actions github-actions bot added conflicts Automatically applied to PRs with merge conflicts documentation Improvements or additions to documentation AutoGPT Agent Forge size/xl labels Apr 25, 2024
    Copy link

    netlify bot commented Apr 25, 2024

    Deploy Preview for auto-gpt-docs canceled.

    Name Link
    🔨 Latest commit 9681973
    🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/6644cd26f1152100086f270e

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    Moved to forge/utils/exceptions.py

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    Merged with exceptions from autogpt into forge/utils/exceptions.py

    @github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Apr 28, 2024
    @github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Apr 29, 2024
    @kcze kcze mentioned this pull request May 1, 2024
    9 tasks
    @kcze kcze changed the title clean(autogpt, forge): Move codebase to forge refactor(autogpt, forge): Move codebase to forge May 1, 2024
    @github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label May 2, 2024
    @Significant-Gravitas Significant-Gravitas deleted a comment from github-actions bot May 2, 2024
    @kcze kcze mentioned this pull request May 12, 2024
    9 tasks
    @@ -32,21 +32,30 @@ class MyAgent(Agent):

    ## Ordering components

    The execution order of components is important because the latter ones may depend on the results of the former ones.
    The execution order of components is important because some may depend on the results of the previous ones.
    **By default, components are ordered alphabetically.**
    Copy link
    Member

    @ntindle ntindle May 13, 2024

    Choose a reason for hiding this comment

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

    sidenote: We should probably resolve this in some other way down the line. Perhaps with a manifest and building a graph

    def __init__(
    self,
    event_history: EpisodicActionHistory[AP],
    max_tokens: int,
    count_tokens: Callable[[str], int],
    legacy_config: Config,
    legacy_config: "Config",
    Copy link
    Member

    Choose a reason for hiding this comment

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

    nit: Do we need this?

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    No, updated

    Copy link
    Member

    Choose a reason for hiding this comment

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

    sidenote: why deleted? Behavior change?

    Copy link
    Contributor Author

    @kcze kcze May 13, 2024

    Choose a reason for hiding this comment

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

    This was a leftover from my initial notes, I may put this back in some form when I update docs after the refactor.
    There's no get_component

    ntindle
    ntindle previously approved these changes May 13, 2024
    Copy link
    Member

    @ntindle ntindle left a comment

    Choose a reason for hiding this comment

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

    few comments but all can be resolved without interaction from me so approving

    Swiftyos
    Swiftyos previously approved these changes May 13, 2024
    Copy link
    Contributor

    @Swiftyos Swiftyos left a comment

    Choose a reason for hiding this comment

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

    LGTM

    @Swiftyos
    Copy link
    Contributor

    Swiftyos commented May 13, 2024

    @kcze Would you like me to force merge it in. Assuming your later PRs eventually fix the CI's

    autogpts/forge/forge/config/config.py Outdated Show resolved Hide resolved
    Copy link
    Member

    Choose a reason for hiding this comment

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

    Sure, a minimal config in forge would be useful.

    autogpts/forge/forge/json/schema.py Outdated Show resolved Hide resolved
    autogpts/forge/forge/utils/input.py Outdated Show resolved Hide resolved
    Copy link
    Member

    @Pwuts Pwuts left a comment

    Choose a reason for hiding this comment

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

    Thanks for addressing the earlier feedback! We're down to 6 unresolved items on my end (so excluding @ntindle's comments, and excluding one which doesn't require any changes) :)

    @github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label May 14, 2024
    Copy link

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

    @Pwuts Pwuts dismissed stale reviews from Swiftyos and ntindle via 84808e2 May 14, 2024 15:29
    @github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label May 15, 2024
    Copy link

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

    @Pwuts Pwuts changed the title refactor(agent, forge): Move codebase to forge refactor(agent, forge): Move library code from autogpt to forge May 15, 2024
    @Pwuts Pwuts merged commit e8d7dfa into Significant-Gravitas:master May 15, 2024
    12 of 17 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    Status: Done
    4 participants