zou-group / textgrad

Automatic ''Differentiation'' via Text -- using large language models to backpropagate textual gradients.
http://textgrad.com/
MIT License
945 stars 67 forks source link

Refactor and Improve textgrad Modules for Better Readability and Maintainability #22

Open sanowl opened 1 week ago

sanowl commented 1 week ago

Description

This pull request refactors and improves the textgrad modules to enhance readability and maintainability. The following changes have been made:

Changes

  1. Grouped and ordered imports logically.
  2. Added detailed docstrings to classes and methods.
  3. Streamlined initialization checks for engines and system prompts.
  4. Improved readability and consistency in string formatting.
  5. Added comments for better understanding of the code.

Testing

All existing functionality has been retained and tested. No new tests were added, but the improvements ensure better maintainability and readability of the codebase.

Additional Notes

This refactoring does not introduce any new functionality. It is aimed at improving the code quality and maintainability.