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

Define user_message_only_models list for using user prompt only model #1509

Merged
merged 8 commits into from
Feb 2, 2025

Conversation

KennyDizi
Copy link
Contributor

@KennyDizi KennyDizi commented Jan 31, 2025

PR Type

Enhancement, Bug fix


Description

  • Added USER_MESSAGE_ONLY_MODELS list to centralize user-message-only model definitions.

  • Included o3-mini and o3-mini-2025-01-31 in supported models.

  • Refactored logic to check for user-message-only models dynamically.

  • Fixed null check for user_message_only_models to prevent errors.


Changes walkthrough 📝

Relevant files
Enhancement
__init__.py
Define and include user-message-only models                           

pr_agent/algo/init.py

  • Added USER_MESSAGE_ONLY_MODELS list for user-message-only models.
  • Included o3-mini and o3-mini-2025-01-31 in model configurations.
  • +12/-0   
    Bug fix
    litellm_ai_handler.py
    Refactor and enhance user-message-only model logic             

    pr_agent/algo/ai_handlers/litellm_ai_handler.py

  • Imported USER_MESSAGE_ONLY_MODELS for centralized model handling.
  • Refactored logic to dynamically check for user-message-only models.
  • Added null check for user_message_only_models to avoid errors.
  • +6/-4     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Error Handling

    The new code checks if user_message_only_models exists before using it, but doesn't handle the case where get_settings().config.user_message_only_models returns None or is malformed

    user_message_only_models = get_settings().config.user_message_only_models
    if user_message_only_models and any(entry in model for entry in user_message_only_models):
    Configuration Validation

    The new user_message_only_models list contains specific version numbers which may need to be updated as new model versions are released

    user_message_only_models=["deepseek/deepseek-reasoner", "o1-mini", "o1-mini-2024-09-12", "o1", "o1-2024-12-17"]

    Copy link
    Contributor

    qodo-merge-pro-for-open-source bot commented Jan 31, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    ✅ Add null safety check
    Suggestion Impact:The commit implemented the suggested null safety check by adding 'or []' as a default value, exactly as suggested

    code diff:

    +            user_message_only_models = get_settings().config.user_message_only_models or []

    Add a null check for user_message_only_models before using it in the any() function
    to prevent potential NoneType errors if the setting is not defined.

    pr_agent/algo/ai_handlers/litellm_ai_handler.py [201-202]

    -user_message_only_models = get_settings().config.user_message_only_models
    +user_message_only_models = get_settings().config.user_message_only_models or []
     if user_message_only_models and any(entry in model for entry in user_message_only_models):
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding a null check is crucial for preventing runtime errors, as the configuration might not always define user_message_only_models. This defensive programming practice significantly improves code reliability.

    8
    General
    ✅ Add case-insensitive model comparison
    Suggestion Impact:The commit implemented case-insensitive model name comparison by adding .lower() to both sides of the comparison

    code diff:

    -            if user_message_only_models and any(entry in model for entry in user_message_only_models):
    +            user_message_only_models = get_settings().config.user_message_only_models or []
    +            if user_message_only_models and any(entry.lower() in model.lower() for entry in user_message_only_models):

    Add case-insensitive model name comparison to prevent issues with model names in
    different cases.

    pr_agent/algo/ai_handlers/litellm_ai_handler.py [202]

    -if user_message_only_models and any(entry in model for entry in user_message_only_models):
    +if user_message_only_models and any(entry.lower() in model.lower() for entry in user_message_only_models):
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Case-insensitive comparison makes the model matching more robust and prevents potential bugs when model names are specified with different casing. This is a valuable improvement for code reliability.

    7
    • Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.

    @KennyDizi
    Copy link
    Contributor Author

    Hi @mrT23 This is the PR to optimize for this PR #1473

    @mrT23
    Copy link
    Collaborator

    mrT23 commented Feb 1, 2025

    thanks for the PR @KennyDizi
    It looks good, but i prefer the 'user_message_only_models' to b here:
    https://github.com/qodo-ai/pr-agent/blob/main/pr_agent/algo/__init__.py

    The configuration file is already packed, and i prefer not to add it another configuration with many models.

    @KennyDizi
    Copy link
    Contributor Author

    Hi @mrT23 it's a good point. I will adjust the code accordingly.

    @KennyDizi
    Copy link
    Contributor Author

    /describe

    Copy link
    Contributor

    PR Description updated to latest commit (a6482c3)

    @KennyDizi
    Copy link
    Contributor Author

    @mrT23 This PR has been updated accordingly.

    @mrT23 mrT23 merged commit d8fba02 into qodo-ai:main Feb 2, 2025
    2 checks passed
    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