MetaGPT icon indicating copy to clipboard operation
MetaGPT copied to clipboard

add deepseek-v2, yi-large and gpt-4o pricing to token_counter

Open usamimeri opened this issue 9 months ago • 4 comments

User description

for usage calculation


PR Type

enhancement


Description

  • Added new model pricing details to the token counter for gpt-4o, gpt-4o-2024-05-13, yi-large, and deepseek-chat.
  • Updated the token counting function to support the newly added models.

Changes walkthrough 📝

Relevant files
Enhancement
token_counter.py
Add Pricing and Token Counting for New Models                       

metagpt/utils/token_counter.py

  • Added pricing details for gpt-4o, gpt-4o-2024-05-13, yi-large, and
    deepseek-chat models.
  • Updated token counting logic to include new models gpt-4o-2024-05-13
    and gpt-4o.
  • +6/-0     

    💡 PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    usamimeri avatar May 15 '24 07:05 usamimeri

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Description updated to latest commit (https://github.com/geekan/MetaGPT/commit/1047abf1f40c6bc460247bba6254c42a6adaa04a)

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are straightforward and localized to specific sections of the code, involving the addition of new model pricing and updating the token counting logic.

    🧪 Relevant tests

    No

    ⚡ Possible issues

    Consistency Issue: The pricing for the new models should be verified for consistency with existing pricing strategies and market rates.

    Hardcoding Values: The hardcoded token prices and model names might make the system less flexible and harder to maintain. Consider using a more dynamic approach or external configuration.

    🔒 Security concerns

    No

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    Add comments to explain the pricing model for new entries

    Consider adding a comment to explain the pricing model or the rationale behind the
    specific pricing values for 'gpt-4o' and 'gpt-4o-2024-05-13'. This will help maintainers
    understand the pricing decisions and ensure consistency in future updates.

    metagpt/utils/token_counter.py [40-41]

    -"gpt-4o": {"prompt": 0.005, "completion": 0.015},
    -"gpt-4o-2024-05-13": {"prompt": 0.005, "completion": 0.015},
    +"gpt-4o": {"prompt": 0.005, "completion": 0.015},  # Pricing based on XYZ factors
    +"gpt-4o-2024-05-13": {"prompt": 0.005, "completion": 0.015},  # Pricing based on XYZ factors
     
    
    Suggestion importance[1-10]: 7

    Why: Adding comments for clarity on pricing decisions is beneficial for maintainability, though not critical for functionality.

    7
    Possible issue
    Verify the tokenization method for newly added models

    The addition of 'gpt-4o' and 'gpt-4o-2024-05-13' in the token counting function should be
    verified for correctness in the context of how tokens are counted. If these models have
    different tokenization methods, adjustments might be necessary.

    metagpt/utils/token_counter.py [231-232]

    -"gpt-4o-2024-05-13",
    -"gpt-4o",
    +"gpt-4o-2024-05-13",  # Verify tokenization method
    +"gpt-4o",  # Verify tokenization method
     
    
    Suggestion importance[1-10]: 6

    Why: Verifying tokenization methods for new models is important to ensure accuracy in token counting, addressing a potential issue in functionality.

    6
    Best practice
    Update the model name to include version or date for consistency

    Ensure that the model name 'deepseek-chat' is consistent with other model naming
    conventions in the dictionary. If the model has a version or date, consider including it
    for clarity and future updates.

    metagpt/utils/token_counter.py [67]

    -"deepseek-chat": {"prompt": 0.00014, "completion": 0.00028},
    +"deepseek-chat-2024-05-13": {"prompt": 0.00014, "completion": 0.00028},  # Assuming the date is relevant
     
    
    Suggestion importance[1-10]: 5

    Why: Ensuring naming consistency is good practice, but the suggestion assumes a date should be added without evidence that it's necessary or standard for all models.

    5

    Codecov Report

    All modified and coverable lines are covered by tests :white_check_mark:

    Project coverage is 70.20%. Comparing base (9ff1e2f) to head (b1c1dd2).

    :exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

    Additional details and impacted files
    @@            Coverage Diff             @@
    ##             main    #1274      +/-   ##
    ==========================================
    - Coverage   70.21%   70.20%   -0.01%     
    ==========================================
      Files         316      316              
      Lines       18866    18866              
    ==========================================
    - Hits        13246    13245       -1     
    - Misses       5620     5621       +1     
    

    :umbrella: View full report in Codecov by Sentry.
    :loudspeaker: Have feedback on the report? Share it here.

    codecov-commenter avatar May 15 '24 08:05 codecov-commenter