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

Add cost analysis functionality #15

Merged
merged 4 commits into from
Mar 22, 2024

Conversation

verovaleros
Copy link
Member

Description

Implemented a function that retrieves the number of messages to translate, calculates the number of total tokens, and then calculates the total cost of the translation based on the current pricing from Open AI.

For each message, we craft the request to be sent to OpenAI and calculate the tokens for that request. In this early implementation, we assume the output tokens will be the same as the input tokens.

The prices are taken from the OpenAI documentation at the time of writing this PR. TODO keywords are added to do a better implementation on the next iteration.

Fixes #11

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • The tool was tested locally with various parameters
  • The tests passed locally

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Retrieves the messages, calculates total tokens and calculates the cost based on some current pricing from OpenAI
@verovaleros verovaleros added the enhancement New feature or request label Mar 22, 2024
@verovaleros verovaleros added this to the v1.0.0 milestone Mar 22, 2024
@verovaleros verovaleros self-assigned this Mar 22, 2024
@verovaleros verovaleros linked an issue Mar 22, 2024 that may be closed by this pull request
@verovaleros verovaleros merged commit 72cf26c into main Mar 22, 2024
4 checks passed
@verovaleros verovaleros deleted the feat-add-cost-analysis-functionality branch March 22, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Add cost analysis functionality
1 participant