SkyaTura / gpt-subb

gpt-subb is a command-line tool to translate and convert subtitles using OpenAI's Chat-GPT language models
GNU General Public License v3.0
15 stars 3 forks source link

Budget limit #14

Open SkyaTura opened 1 year ago

SkyaTura commented 1 year ago

TL;DR: OpenAI is draining out my money while I attempt designing better prompts, and I need to pause for a while.


I finally took some time to improve this project, and I have many things in mind for it, as indicated by the issues I've tracked earlier today.

However, even though this is an open source project and I don't pretend to charge for it, developing with OpenAI's API can become really expensive in just a few minutes. Specially because subtitles are large files which consume many tokens for each run, and designing consistent prompts require a lot of trials.

This being said, since I already reached my monthly budget, I will need to pause the development until next billing cycle.

ishaan-jaff commented 1 year ago

@SkyaTura You can use LiteLLM to fix your issue: https://github.com/BerriAI/litellm

LiteLLM - allows you to use any LLM as a drop in replacement fot gpt-3.5-turbo + You can set a $ budget per user or per session

from litellm import BudgetManager, completion 
budget_manager = BudgetManager(project_name="test_project")
user = "1234"

# create a budget if new user user
if not budget_manager.is_valid_user(user):
    budget_manager.create_budget(total_budget=10, user=user)

# check if a given call can be made
if budget_manager.get_current_cost(user=user) <= budget_manager.get_total_budget(user):
    # call gpt-3.5
    response = completion(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hey, how's it going?"}])
    budget_manager.update_cost(completion_obj=response, user=user)
else:
    response = "Sorry - no budget!"
SkyaTura commented 1 year ago

Thank you @ishaan-jaff , I'll take a look