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/config): Modularize Config and revive Azure support #6497

Merged
merged 6 commits into from
Dec 5, 2023

Conversation

Pwuts
Copy link
Member

@Pwuts Pwuts commented Dec 4, 2023

Background

Modular config helps maintainability and manageability of config access throughout the application.

Changes 🏗️

Highlights ✨

  • Significantly increased maintainability of config
  • Azure support is back! 🚀

Full list of changes

  • Refactored the Config + ConfigBuilder to support modular loading and initialization of the configuration from environment variables.
    • Implemented recursive loading and initialization of nested config objects in autogpt.core.configuration.schema.
      • Added the from_env attribute to the UserConfigurable decorator to provide environment variable mappings.
      • Enable validation of assignment operations on SystemConfiguration and SystemSettings objects.
  • Updated LoggingConfig and TTSConfig to use the UserConfigurable decorator for their fields.
  • Updated applicable test cases to reflect the changes in the config loading and initialization logic.
  • Move OpenAI API key and other OpenAI credentials from the global config to a new sub-config called OpenAICredentials.
    • Update the necessary code to use the new OpenAICredentials sub-config instead of the global config when accessing OpenAI credentials.
    • (Hopefully) unbreak Azure support.
      • Update azure.yaml.template.
  • Added new configuration options for logging and OpenAI usage to .env.template
  • Removed deprecated configuration options in config/config.py
  • Updated setup instructions in Docker and general setup documentation to include information on using Azure's OpenAI services

This refactor improves the flexibility and maintainability of the configuration loading process by introducing modular and recursive behavior, allowing for easier extension and customization through environment variables.

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

Copy link
Contributor

github-actions bot commented Dec 4, 2023

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

Copy link

netlify bot commented Dec 4, 2023

Deploy Preview for auto-gpt-docs ready!

Name Link
🔨 Latest commit 21a36f0
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/656f3e8c1469b4000845da25
😎 Deploy Preview https://deploy-preview-6497--auto-gpt-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Pwuts Pwuts added function: config code quality ⬆️ PRs that improve code quality labels Dec 4, 2023
@Pwuts Pwuts self-assigned this Dec 4, 2023
@Pwuts Pwuts added this to the Auto-GPT v0.5.0 milestone Dec 4, 2023
@Auto-GPT-Bot
Copy link
Contributor

You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged.

@Pwuts Pwuts force-pushed the agent/modular-config branch from 4f5b16e to 1258b01 Compare December 4, 2023 14:43
Copy link
Contributor

github-actions bot commented Dec 4, 2023

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

@Auto-GPT-Bot
Copy link
Contributor

You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged.

@Pwuts Pwuts added the re-arch label Dec 4, 2023
…centralized

- Refactored the `ConfigBuilder` class to support modular loading and initialization of the configuration from environment variables.
- Implemented recursive loading and initialization of nested config objects.
- Introduced the `SystemConfiguration` base class to provide common functionality for all system settings.
- Added the `from_env` attribute to the `UserConfigurable` decorator to provide environment variable mappings.
- Updated the `Config` class and its related classes to inherit from `SystemConfiguration` and use the `UserConfigurable` decorator.
- Updated `LoggingConfig` and `TTSConfig` to use the `UserConfigurable` decorator for their fields.
- Modified the implementation of the `build_config_from_env` method in `ConfigBuilder` to utilize the new modular and recursive loading and initialization logic.
- Updated applicable test cases to reflect the changes in the config loading and initialization logic.

This refactor improves the flexibility and maintainability of the configuration loading process by introducing modular and recursive behavior, allowing for easier extension and customization through environment variables.
@Pwuts Pwuts force-pushed the agent/modular-config branch from 1258b01 to a3d74bb Compare December 4, 2023 15:22
Copy link
Contributor

github-actions bot commented Dec 4, 2023

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

1 similar comment
Copy link
Contributor

github-actions bot commented Dec 5, 2023

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

- Move OpenAI API key and other OpenAI credentials from the global config to a new sub-config called OpenAICredentials.
- Update the necessary code to use the new OpenAICredentials sub-config instead of the global config when accessing OpenAI credentials.
- (Hopefully) unbreak Azure support.
   - Update azure.yaml.template.
- Enable validation of assignment operations on SystemConfiguration and SystemSettings objects.
@Pwuts Pwuts force-pushed the agent/modular-config branch from 58eedf6 to 6728ba0 Compare December 5, 2023 13:34
Copy link
Contributor

github-actions bot commented Dec 5, 2023

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

- Added new configuration options for logging and OpenAI usage to .env.template
- Removed deprecated configuration options in config/config.py
- Updated setup instructions in Docker and general setup documentation to include information on using Azure's OpenAI services
Copy link
Contributor

github-actions bot commented Dec 5, 2023

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

- Fix issue with image generation with Dall-E API

Additional user context: This commit fixes an issue with image generation using the Dall-E API. The code now correctly retrieves the API key from the agent's legacy configuration.
Copy link
Contributor

github-actions bot commented Dec 5, 2023

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

@Auto-GPT-Bot
Copy link
Contributor

You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged.

@Pwuts Pwuts marked this pull request as ready for review December 5, 2023 14:31
Copy link
Contributor

github-actions bot commented Dec 5, 2023

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

@Pwuts Pwuts changed the title Agent: Implement modular config refactor(agent/config): Modularize Config and revive Azure support Dec 5, 2023
Copy link
Contributor

github-actions bot commented Dec 5, 2023

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

…d update docstrings

- Refactor the `schema.py` file in the `autogpt.core.configuration` module.
- Added docstring to `SystemConfiguration.from_env()`
- Updated docstrings for functions `_get_user_config_values`, `_get_non_default_user_config_values`, `_recursive_init_model`, `_recurse_user_config_fields`, and `_recurse_user_config_values`.
@Pwuts Pwuts force-pushed the agent/modular-config branch from 9b6ad16 to 21a36f0 Compare December 5, 2023 15:15
Copy link
Contributor

github-actions bot commented Dec 5, 2023

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

@Pwuts Pwuts merged commit 7b05245 into master Dec 5, 2023
16 checks passed
@Pwuts Pwuts deleted the agent/modular-config branch December 5, 2023 15:28
@Pwuts Pwuts mentioned this pull request Dec 5, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants