AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

startup menu for ai_settings.yaml to support multiple configurations

Open bassie661 opened this issue 2 years ago • 84 comments

User description

Summary

I created this PR to add support for storing multiple configurations, thus allowing the user to 'create', 'edit', 'view' or 'delete' configurations and have their settings stored in ai_settings.yaml. The ai_settings file now saves configurations as dictionary and if a configuration exists it is showed as a menu option when autogpt is started.

When no configurations are found, or no ai_settings.yaml file, the user get's the usual generate_aiconfig_automatic questions and can choose to either let autogpt create the config from a single input or the user can choose "--manual" to manually input the first configuration. At the end of this process the first configuration is saved in the ai_settings file.

Next time when autogpt starts and/or when configurations are found in ai_settings.yaml, the prompt starts-up with the following menu:

image

Change

  • Support storing multiple AI configurations
  • Support choose existing AI configuration(s)
  • Support create new AI configuration(s)
  • Support edit existing AI configuration(s)
  • Support view existing AI configuration(s)
  • Support delete existing AI configuration(s) -> e.g. ai_name, ai_role, ai_goals[], api_budget, plugins
  • Support for plugins per AI configuration (add, delete, change), plugins are expected to land with #4089

This PR is big but it was needed to restructure the old and add the new functionality to the '--manual' startup flow while keeping the functionality clear and maintainable.

  • Initial plan was to also add support for setting temperature (ai_temp) per AI configuration (add, delete, change) but this clearly needs extra changes, so a separate PR for ai_temp support is needed.
  • This is a new approach which rendered #3711 and #4478 obsolete.
  • I had to rewrite a lot of parts to keep up with the commits and release of v0.4.0 / v0.4.1 and v0.4.2
  • added support for #4666

Test Plan

  • integration\test_setup.py
  • unit\test_ai_config.py
  • unit\test_config.py
  • unit\test_prompt.py

PR Quality Checklist

[x] My pull request is atomic and focuses on a single change. -> mostly true but reworking the old startup prompts was quite complex which inevitably needed more than 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. [x] I have run the following commands against my code to ensure it passes our linters: black . / isort . / mypy autoflake --remove-all-unused-imports --recursive --ignore-init-module-imports autogpt tests --in-place


PR Type

Enhancement, Tests


Description

  • Added support for storing and managing multiple AI configurations, including plugins.
  • Refactored prompt handling to introduce a new interactive menu for configuration management.
  • Integrated automatic configuration generation with the new menu system.
  • Added comprehensive unit and integration tests for the new features.

Changes walkthrough 📝

Relevant files
Enhancement
5 files
ai_config.py
Support for multiple AI configurations with plugins           

autogpt/config/ai_config.py

  • Added support for plugins in AI configurations.
  • Introduced methods for loading, saving, and deleting multiple AI
    configurations.
  • Updated configuration format to support multiple configurations.
  • +234/-41
    config.py
    Added plugin management and ai_settings_filepath                 

    autogpt/config/config.py

  • Added methods to set plugins allowlist and denylist.
  • Introduced ai_settings_filepath attribute.
  • +13/-1   
    main.py
    Main entry point modifications for configuration management

    autogpt/main.py

  • Modified main entry point to support new configuration management.
  • Added start_agent_directly function for direct agent start from menu.
  • +59/-4   
    prompt.py
    Refactored prompt handling and configuration management   

    autogpt/prompts/prompt.py

  • Refactored prompt handling to support new configuration menu.
  • Added functions for managing AI configurations interactively.
  • +811/-44
    setup.py
    Integrated automatic configuration with new menu system   

    autogpt/setup.py

  • Removed manual configuration setup.
  • Integrated automatic configuration generation with new menu system.
  • +40/-162
    Tests
    4 files
    test_setup.py
    Integration tests for configuration management                     

    tests/integration/test_setup.py

  • Added integration tests for new configuration management features.
  • Tested various scenarios including creation, deletion, and editing of
    configurations.
  • +765/-39
    test_ai_config.py
    Unit tests for AIConfig class                                                       

    tests/unit/test_ai_config.py

  • Added unit tests for AIConfig class methods.
  • Tested loading, saving, and deleting configurations.
  • +421/-45
    test_config.py
    Unit tests for plugin management in Config class                 

    tests/unit/test_config.py

  • Added unit tests for new plugin management methods in Config class.
  • +30/-0   
    test_prompt.py
    Unit tests for prompt handling functions                                 

    tests/unit/test_prompt.py

  • Added unit tests for prompt handling functions.
  • Tested validation and management of AI names.
  • +162/-0 

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

    bassie661 avatar Jun 10 '23 19:06 bassie661

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

    1 Ignored Deployment
    Name Status Preview Comments Updated (UTC)
    docs ⬜️ Ignored (Inspect) Jun 12, 2023 5:16pm

    vercel[bot] avatar Jun 10 '23 19:06 vercel[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 10 '23 19:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 08:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 15:06 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 Jun 11 '23 15:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 15:06 github-actions[bot]

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

    github-actions[bot] avatar Jun 11 '23 15:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 15:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 16:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 16:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 16:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 16:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 16:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 16:06 github-actions[bot]

    Codecov Report

    Attention: Patch coverage is 74.27293% with 115 lines in your changes missing coverage. Please review.

    Project coverage is 71.47%. Comparing base (32038c9) to head (b077bce). Report is 3196 commits behind head on master.

    Files Patch % Lines
    autogpt/prompts/prompt.py 78.68% 43 Missing and 22 partials :warning:
    autogpt/main.py 17.85% 23 Missing :warning:
    autogpt/setup.py 18.18% 18 Missing :warning:
    autogpt/config/ai_config.py 90.58% 5 Missing and 3 partials :warning:
    autogpt/config/config.py 85.71% 1 Missing :warning:
    Additional details and impacted files
    @@            Coverage Diff             @@
    ##           master    #4646      +/-   ##
    ==========================================
    + Coverage   70.63%   71.47%   +0.83%     
    ==========================================
      Files          67       68       +1     
      Lines        3239     3667     +428     
      Branches      514      606      +92     
    ==========================================
    + Hits         2288     2621     +333     
    - Misses        783      848      +65     
    - Partials      168      198      +30     
    

    :umbrella: View full report in Codecov by Sentry.
    :loudspeaker: Have feedback on the report? Share it here.

    codecov[bot] avatar Jun 11 '23 16:06 codecov[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 19:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 11 '23 20:06 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 Jun 11 '23 22:06 github-actions[bot]

    Deploy Preview for auto-gpt-docs failed.

    Name Link
    Latest commit b077bcefdfa18d0d167202b574f96e6299cd49b9
    Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/64969959f04b3700089bab96

    netlify[bot] avatar Jun 12 '23 17:06 netlify[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 12 '23 17:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 13 '23 11:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 13 '23 11:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 13 '23 13:06 github-actions[bot]

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

    github-actions[bot] avatar Jun 13 '23 13:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 13 '23 13:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 13 '23 22:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 13 '23 22:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 13 '23 23:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 13 '23 23:06 github-actions[bot]

    This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.

    github-actions[bot] avatar Jun 14 '23 06:06 github-actions[bot]