forked from phoenix/litellm-mirror
(fix) together_ai cost tracking
This commit is contained in:
parent
a351211d03
commit
d79df3a1e9
2 changed files with 4 additions and 3 deletions
|
@ -215,7 +215,7 @@ def completion(
|
||||||
"choices"
|
"choices"
|
||||||
][0]["finish_reason"]
|
][0]["finish_reason"]
|
||||||
model_response["created"] = int(time.time())
|
model_response["created"] = int(time.time())
|
||||||
model_response["model"] = model
|
model_response["model"] = "together_ai/" + model
|
||||||
usage = Usage(
|
usage = Usage(
|
||||||
prompt_tokens=prompt_tokens,
|
prompt_tokens=prompt_tokens,
|
||||||
completion_tokens=completion_tokens,
|
completion_tokens=completion_tokens,
|
||||||
|
|
|
@ -2644,7 +2644,7 @@ def completion_cost(
|
||||||
completion_tokens = token_counter(model=model, text=completion)
|
completion_tokens = token_counter(model=model, text=completion)
|
||||||
|
|
||||||
# Calculate cost based on prompt_tokens, completion_tokens
|
# Calculate cost based on prompt_tokens, completion_tokens
|
||||||
if "togethercomputer" in model:
|
if "togethercomputer" in model or "together_ai" in model:
|
||||||
# together ai prices based on size of llm
|
# together ai prices based on size of llm
|
||||||
# get_model_params_and_category takes a model name and returns the category of LLM size it is in model_prices_and_context_window.json
|
# get_model_params_and_category takes a model name and returns the category of LLM size it is in model_prices_and_context_window.json
|
||||||
model = get_model_params_and_category(model)
|
model = get_model_params_and_category(model)
|
||||||
|
@ -2661,7 +2661,8 @@ def completion_cost(
|
||||||
completion_tokens=completion_tokens,
|
completion_tokens=completion_tokens,
|
||||||
)
|
)
|
||||||
return prompt_tokens_cost_usd_dollar + completion_tokens_cost_usd_dollar
|
return prompt_tokens_cost_usd_dollar + completion_tokens_cost_usd_dollar
|
||||||
except:
|
except Exception as e:
|
||||||
|
print_verbose(f"LiteLLM: Excepton when cost calculating {str(e)}")
|
||||||
return 0.0 # this should not block a users execution path
|
return 0.0 # this should not block a users execution path
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue