Estimate approximate cost and total cost #61
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the
--estimation
flag, which allows for the approximate cost calculation of documenting a repository, folder, or file without making any GPT calls. However, it is not entirely precise, as it requires aggregating the output tokens (GPT answer) and the JSON data generated by theextract_code_elements
function, which is used as part of the input for the process. Nonetheless, this cost estimation provides a rough idea of what will be the minimum cost.In addition, this PR enhances the code to always display the total cost after documenting the code, which yield a more accurate result since GPT calls are made, and the cost calculation takes into account both the output tokens and the generated JSON data for functions and classes.
For illustration, using a testing repository, the approximate cost was $2.4473 (no GPT calls done), and the total cost came to $2.9576 (GPT calls done).