[X] I added a very descriptive title to this issue.
[X] I searched the LangChain documentation with the integrated search.
[X] I used the GitHub search to find a similar question and didn't find it.
[X] I am sure that this is a bug in LangChain rather than my code.
[X] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
from langchain_aws import ChatBedrock
from langchain_community.callbacks.manager import get_bedrock_anthropic_callback
llm = ChatBedrock(model_id="anthropic.claude-3-haiku-20240307-v1:0")
# llm = ChatBedrock(model_id="anthropic.claude-v2")
with get_bedrock_anthropic_callback() as cb:
result = llm.invoke("Tell me a joke")
result2 = llm.invoke("Tell me a joke")
print(cb)
Error Message and Stack Trace (if applicable)
This is not an error, but rather the actual behavior.
As shown on the referenced page -> Tracking token usage.
Description:
I encountered an issue with the get_bedrock_anthropic_callback function in Langchain. According to the documentation, the function should provide token usage details, but it returns all token values as 0.
Steps to Reproduce:
Use get_bedrock_anthropic_callback as described in the documentation.
Observe that token values are returned as 0.
Expected Behavior:
The function should return the correct token usage values.
Actual Behavior:
The function returns all token values as 0.
Considering the use of Claude 3 Opus, it would be beneficial to include Opus (anthropic.claude-3-opus-20240229-v1:0) in the model cost mapping. Here are the current values for reference:
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
This is not an error, but rather the actual behavior. As shown on the referenced page -> Tracking token usage.
Description
Description: I encountered an issue with the get_bedrock_anthropic_callback function in Langchain. According to the documentation, the function should provide token usage details, but it returns all token values as 0.
Steps to Reproduce:
Use get_bedrock_anthropic_callback as described in the documentation. Observe that token values are returned as 0. Expected Behavior: The function should return the correct token usage values.
Actual Behavior: The function returns all token values as 0.
Considering the use of Claude 3 Opus, it would be beneficial to include Opus (anthropic.claude-3-opus-20240229-v1:0) in the model cost mapping. Here are the current values for reference:
langchain_community.callbacks.bedrock_anthropic_callback
System Info
Langchain: langchain==0.2.0rc2 langchain-anthropic==0.1.12 langchain-aws==0.1.3 langchain-chroma==0.1.0 langchain-community==0.2.0rc1 langchain-core==0.1.52 langchain-openai==0.1.6 langchain-text-splitters==0.0.1
OS: windows10
Python: 3.10.4