Refactor Commit Message Generation with Improved API Support #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description: Refactor Commit Message Generation with Improved API Support
Overview
This PR refactors the commit message generation logic by consolidating local and remote model handling into a unified function, improving maintainability and clarity. It also adds a robust URL parsing method and enhances error handling for improved stability in diverse environments. The main benefit here is that it eliminates the need for another library to be installed and imported.
Key Changes
Unified
generate_commit_message
Function:remote
flag to switch between local and remote models.Enhanced API Key Handling:
get_api_key
to accept aremote
parameter, supporting both local and remote models dynamically.Improved URL Handling:
parse_host
to handle URL parsing, ensuring compatibility with IPv6 and custom ports.Error Handling & Encoding:
Code Simplification:
interaction_loop
.Benefits
This refactor positions the application for future scalability and ensures a smoother user experience.