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

Managing OpenAI usage and costs #41

Open
ChristianIvicevic opened this issue Feb 2, 2023 · 5 comments
Open

Managing OpenAI usage and costs #41

ChristianIvicevic opened this issue Feb 2, 2023 · 5 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@ChristianIvicevic
Copy link

Greetings,

out of curiosity I tried out gptcommit yesterday for the first time with three commits. Two of them were a bit larger with 265 additions and 214 deletions according to git. Much to my surprise there were two dozen requests and got billed for $0.55. I'd like to ask whether it's expected that the amount of requests (and thus the price) is that high or whether this might indicate a bug?

image

@zurawiki
Copy link
Owner

zurawiki commented Feb 2, 2023

Hey @ChristianIvicevic , you bring up a great point here.

In the current design, gptcommit issues N+2 prompts, where N is the number of modified files with diffs under the max_token_limit. The other prompts are the title and summary.

OpenAI Completions are billed by "tokens" that are both sent and generated. Pricing per token depends on the model used. The number of tokens generated are generally predictable (as a commit message is usually only so big) but gptcommit could be sending over a lot of tokens in the form of diff data.

Today, I see two low-hanging solutions for reducing cost:

  • Switch to a different model using the openai.model configuration option
  • Reduce the side of prompts and diff data sent to OpenAI

OpenAI's pricing page can be found at
https://openai.com/api/pricing/#faq-completions-pricing

@zurawiki zurawiki added the question Further information is requested label Feb 2, 2023
@ChristianIvicevic
Copy link
Author

Thanks for the summary. I might have a proposal that may be an option to take into consideration. As of right now I can technically create a patch for a specific commit and without its subject line ask ChatGPT about a descriptive commit message. Unlike gptcommit it would not summarize the changes of each touched file, but it's basically a single sentence or paragraph based on a patch file.

Given that GPT can't explain the reasoning behind certain changes summarizing the details of each file feels less valuable so I'd like to know whether the described approach with less output might be a feature of gptcommit to condense output and maybe reduce costs.

@zurawiki
Copy link
Owner

zurawiki commented Feb 2, 2023 via email

@zurawiki zurawiki added the help wanted Extra attention is needed label Feb 2, 2023
@zurawiki zurawiki changed the title Clarification on the amount of requests Managing OpenAI usage and costs Feb 4, 2023
@zcf0508
Copy link
Contributor

zcf0508 commented Feb 22, 2023

@zurawiki
Copy link
Owner

zurawiki commented Mar 3, 2023

Given the new Chat GPT models and cheaper pricing, is this issue still relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants