Skip to content

Commit fbd1a62

Browse files
skoob13Radu-Raicea
andauthored
Update posthog/ai/langchain/callbacks.py
Co-authored-by: Radu Raicea <[email protected]>
1 parent 9bd032a commit fbd1a62

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

posthog/ai/langchain/callbacks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,8 @@ def _parse_usage_model(
756756
for mapped_key, dataclass_key in field_mapping.items()
757757
},
758758
)
759-
# input_tokens is the sum of input and cache read tokens.
759+
# In LangChain, input_tokens is the sum of input and cache read tokens.
760+
# Our cost calculation expects them to be separate, for Anthropic.
760761
if normalized_usage.input_tokens and normalized_usage.cache_read_tokens:
761762
normalized_usage.input_tokens = max(
762763
normalized_usage.input_tokens - normalized_usage.cache_read_tokens, 0

0 commit comments

Comments
 (0)