You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Remove redundant condition to simplify code structure
The condition if enable_custom_labels: is redundant because it's always true when the inner condition is checked. Consider removing the outer condition to simplify the code structure.
Why: The suggestion is correct and improves code efficiency slightly, but the impact is minimal as the str() function is idempotent for string inputs.
5
Maintainability
Use a constant for the empty system prompt instead of a hardcoded value
Consider using a constant or configuration value for the empty system prompt instead of a hardcoded newline character. This would make the code more maintainable and allow for easier changes in the future.
+EMPTY_SYSTEM_PROMPT = "\n"
if 'claude' in model and not system:
- system = "\n"+ system = EMPTY_SYSTEM_PROMPT
get_logger().warning(
- "Empty system prompt for claude model. Adding a newline character to prevent OpenAI API error.")+ f"Empty system prompt for claude model. Adding '{EMPTY_SYSTEM_PROMPT}' to prevent OpenAI API error.")
Apply this suggestion
Suggestion importance[1-10]: 7
Why: Using a constant improves maintainability and readability, but the current implementation is functional and the change is not critical.
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 Type
Enhancement, Bug fix
Description
litellm_ai_handler.py
when using Claude modelutils.py
:Changes walkthrough 📝
litellm_ai_handler.py
Error handling for empty system prompt
pr_agent/algo/ai_handlers/litellm_ai_handler.py
error
utils.py
Improved error handling and type conversion
pr_agent/algo/utils.py