forked from phoenix/litellm-mirror
fix(utils.py): fix azure completion cost calculation
This commit is contained in:
parent
7ee089b5ca
commit
b4b7acdb72
2 changed files with 2 additions and 4 deletions
|
@ -863,7 +863,7 @@ async def model_info(request: Request):
|
|||
model_name = m["model_name"]
|
||||
model_params = {}
|
||||
for k,v in m["litellm_params"].items():
|
||||
if k == "api_key": # don't send the api key
|
||||
if k == "api_key" or k == "api_base": # don't send the api key or api base
|
||||
continue
|
||||
|
||||
if k == "model":
|
||||
|
|
|
@ -1660,8 +1660,6 @@ def cost_per_token(model="", prompt_tokens=0, completion_tokens=0):
|
|||
"gpt-35-turbo-16k": "azure/gpt-3.5-turbo-16k",
|
||||
"gpt-35-turbo-instruct": "azure/gpt-3.5-turbo-instruct"
|
||||
}
|
||||
if "azure/" in model:
|
||||
model = model.replace("azure/", "")
|
||||
if model in model_cost_ref:
|
||||
prompt_tokens_cost_usd_dollar = (
|
||||
model_cost_ref[model]["input_cost_per_token"] * prompt_tokens
|
||||
|
@ -1741,7 +1739,7 @@ def completion_cost(
|
|||
# Handle Inputs to completion_cost
|
||||
prompt_tokens = 0
|
||||
completion_tokens = 0
|
||||
if completion_response != None:
|
||||
if completion_response is not None:
|
||||
# get input/output tokens from completion_response
|
||||
prompt_tokens = completion_response['usage']['prompt_tokens']
|
||||
completion_tokens = completion_response['usage']['completion_tokens']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue