Skip to content

Conversation

@shreyashkgupta
Copy link
Collaborator

@shreyashkgupta shreyashkgupta commented May 29, 2024

Pull Request Description: Token Counter Fix

Summary

This pull request addresses a bug in the token counting functionality within the kaizen/llms/provider.py file. The main purpose of this change is to correct the way the litellm.token_counter function is called, ensuring that the parameters are passed correctly.

Significant Modifications

  1. Bug Fix in Token Counter Function: The get_token_count method in kaizen/llms/provider.py has been updated to pass the parameters to litellm.token_counter using keyword arguments (model=self.model, text=message) instead of positional arguments. This change ensures that the function receives the correct inputs and operates as expected.

  2. Version Update: The project version in pyproject.toml has been incremented from 0.1.14 to 0.1.15 to reflect the bug fix and maintain proper versioning.

Impact

  • Error Handling: This fix improves the reliability of the token counting functionality, preventing potential errors caused by incorrect parameter passing.
  • Maintainability: By using keyword arguments, the code is more readable and less prone to errors, enhancing maintainability.

Please review the changes and provide feedback or approval as necessary.

✨ Generated with love by Kaizen ❤️

Original Description None

@shreyashkgupta shreyashkgupta merged commit c194726 into main May 29, 2024
@cloudcodeai-nightly
Copy link

Code Review

✅ This is a good review! 👍

Here are some feedback:

Potential Issues

[important] -> The `update_usage` method does not handle the case where `total_usage` is `None`. This could potentially lead to unexpected behavior or errors. **Fix:** Consider adding a check to handle the case where `total_usage` is `None` to ensure the method behaves as expected. kaizen/llms/provider.py | 82 - 83

✨ Generated with love by Kaizen ❤️

@kaizen-bot
Copy link
Contributor

kaizen-bot bot commented May 30, 2024

Code Review

✅ This is a good review! 👍

Here are some feedback:

Potential Issues

[important] -> The `update_usage` method does not handle the case where `total_usage` is `None`. This could lead to potential issues if `total_usage` is expected to be an integer or float. **Fix:** Consider adding a check to handle the case where `total_usage` is `None` to avoid potential errors. kaizen/llms/provider.py | 82 - 83

✨ Generated with love by Kaizen ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants