mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
Using typed dict in usage_details
This commit is contained in:
parent
a3614e0d07
commit
bd0369dd88
1 changed files with 5 additions and 7 deletions
|
|
@ -642,7 +642,7 @@ class LangFuseLogger:
|
|||
|
||||
generation_id = None
|
||||
usage = None
|
||||
usage_details : Optional[LangfuseUsageDetails] = None
|
||||
usage_details = None
|
||||
if response_obj is not None:
|
||||
if (
|
||||
hasattr(response_obj, "id")
|
||||
|
|
@ -659,12 +659,10 @@ class LangFuseLogger:
|
|||
"completion_tokens": _usage_obj.completion_tokens,
|
||||
"total_cost": cost if self._supports_costs() else None,
|
||||
}
|
||||
usage_details = {
|
||||
"input": _usage_obj.prompt_tokens,
|
||||
"output": _usage_obj.completion_tokens,
|
||||
"cache_creation_input_tokens": _usage_obj.get('cache_creation_input_tokens', 0),
|
||||
"cache_read_input_tokens": _usage_obj.get('cache_read_input_tokens', 0)
|
||||
}
|
||||
usage_details = LangfuseUsageDetails(input=_usage_obj.prompt_tokens,
|
||||
output=_usage_obj.completion_tokens,
|
||||
cache_creation_input_tokens=_usage_obj.get('cache_creation_input_tokens', 0),
|
||||
cache_read_input_tokens=_usage_obj.get('cache_read_input_tokens', 0))
|
||||
|
||||
generation_name = clean_metadata.pop("generation_name", None)
|
||||
if generation_name is None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue