Skip to content

Commit 827fd1d

Browse files
pbvigneshvignesh-pattalam-zoomrxhassiebp
authored
fix(langchain): add support for capturing usage details with ChatBedrock (#1267)
Co-authored-by: Vignesh Pb <[email protected]> Co-authored-by: Hassieb Pakzad <[email protected]>
1 parent b5505b2 commit 827fd1d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

langfuse/langchain/CallbackHandler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,9 @@ def _parse_usage_model(usage: typing.Union[pydantic.BaseModel, dict]) -> Any:
994994
("input_tokens", "input"),
995995
("output_tokens", "output"),
996996
("total_tokens", "total"),
997+
# ChatBedrock API follows a separate format compared to ChatBedrockConverse API
998+
("prompt_tokens", "input"),
999+
("completion_tokens", "output"),
9971000
# https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/get-token-count
9981001
("prompt_token_count", "input"),
9991002
("candidates_token_count", "output"),

0 commit comments

Comments
 (0)