chore: C2 DELETE 204+body, C4 cached_tokens, C5 utcnow + LICENSE (T011)
tests / pytest (push) Has been cancelled

This commit is contained in:
implementation_engineer
2026-07-06 07:33:38 +02:00
parent efc4eab542
commit fcc9b22ec0
4 changed files with 37 additions and 6 deletions
+10
View File
@@ -72,10 +72,20 @@ async def chat(
usage = {}
if hasattr(response, "usage") and response.usage:
# LiteLLM exposes cached prompt tokens via prompt_tokens_details.cached_tokens
# (see litellm.types.utils.Usage). Providers like Anthropic/OpenAI surface this
# when prompt caching is active; surfacing it here flows through LLMResponse.usage
# to any audit log that serialises the usage dict.
cached_tokens = 0
details = getattr(response.usage, "prompt_tokens_details", None)
if details is not None:
cached_tokens = getattr(details, "cached_tokens", None) or 0
usage = {
"prompt_tokens": response.usage.prompt_tokens or 0,
"completion_tokens": response.usage.completion_tokens or 0,
"total_tokens": response.usage.total_tokens or 0,
"cached_tokens": cached_tokens,
"finish_reason": response.choices[0].finish_reason or "stop",
}