feat: add anthropic cached token values for local backends that support it
This commit is contained in:
parent
1d012a92ef
commit
04bc69993d
3 changed files with 93 additions and 16 deletions
|
|
@ -90,7 +90,8 @@ def _serve_cache_hit(cached: bytes, message_id: str, stream: bool):
|
|||
obj = orjson.loads(cached)
|
||||
obj["id"] = message_id
|
||||
u = obj.get("usage") or {}
|
||||
read = u.get("input_tokens", 0) or 0
|
||||
# Whole prompt served from cache: fold the stored uncached + read tokens into read.
|
||||
read = (u.get("input_tokens", 0) or 0) + (u.get("cache_read_input_tokens", 0) or 0)
|
||||
obj["usage"] = {
|
||||
**u,
|
||||
"input_tokens": 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue