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

Estimate approximate cost and total cost #61

Merged
merged 4 commits into from
Sep 26, 2023
Merged

Conversation

betogaona7
Copy link
Collaborator

@betogaona7 betogaona7 commented Sep 25, 2023

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 the extract_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).

@betogaona7 betogaona7 added the enhancement New feature or request label Sep 25, 2023
@betogaona7 betogaona7 requested a review from giorgiop September 25, 2023 19:47
@betogaona7 betogaona7 self-assigned this Sep 25, 2023
Copy link
Contributor

@giorgiop giorgiop left a comment

Choose a reason for hiding this comment

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

LGTM. let's add a short example in the README when we talk about costs

cli.py Outdated Show resolved Hide resolved
devtale/constants.py Show resolved Hide resolved
cli.py Outdated Show resolved Hide resolved
cli.py Outdated Show resolved Hide resolved
@betogaona7 betogaona7 merged commit b50faf7 into main Sep 26, 2023
@betogaona7 betogaona7 deleted the feat/estimate-cost branch September 26, 2023 13:09
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.

2 participants