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

Fix: Rounding error showing cost #293

Conversation

AvdiuAndin
Copy link
Contributor

📘 Description
The logging of session cost value gave an imprecise decimal value.

🔄 Related Issue (if applicable)
#284

🎯 Goal
Ensure precise and accurate rounding of decimal value when logging Cost of the session

🔍 Additional Context
The quantize method in the decimal module is used to round a Decimal object to a specified precision. It requires a Decimal argument that indicates the desired precision and an optional rounding strategy.

How quantize Works
Precision Specification: By passing a Decimal value that represents the desired precision, we can control the number of decimal places to which the value is rounded. For example, Decimal('0.0000001') specifies that we want to round to six decimal places.
Rounding Strategy: The method supports various rounding strategies. In our case, we used ROUND_HALF_UP, which rounds the number to the nearest neighbor, with ties (a digit exactly in the middle, i.e., 5) rounding up.

🧪 Testing

@AvdiuAndin AvdiuAndin linked an issue Jul 10, 2024 that may be closed by this pull request
Copy link
Contributor

@bboynton97 bboynton97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR

jk :) lgtm!

@bboynton97 bboynton97 merged commit 5c7cb7f into AgentOps-AI:main Jul 18, 2024
1 check passed
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.

Cost as decimal returns floating point errors
2 participants