mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-29 08:27:43 +00:00
chore: log cost object (#829)
This commit is contained in:
@@ -139,4 +139,16 @@ class LiteLLMAPIBackend(APIBackend):
|
||||
logger.info(
|
||||
f"Current Cost: ${float(cost):.10f}; Accumulated Cost: ${float(ACC_COST):.10f}; {finish_reason=}",
|
||||
)
|
||||
prompt_tokens = token_counter(model=model, messages=messages)
|
||||
completion_tokens = token_counter(model=model, text=content)
|
||||
logger.log_object(
|
||||
{
|
||||
"model": model,
|
||||
"prompt_tokens": prompt_tokens,
|
||||
"completion_tokens": completion_tokens,
|
||||
"cost": cost,
|
||||
"accumulated_cost": ACC_COST,
|
||||
},
|
||||
tag="token_cost",
|
||||
)
|
||||
return content, finish_reason
|
||||
|
||||
Reference in New Issue
Block a user