-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ChatBedrockConverse sudden interruption and return: TypeError: Additional kwargs key latencyMs already exists in left dict and value has unsupported type <class 'int'>. #223
Comments
I have this same Issue |
@DiogoPM9 File "/Users/pijain/projects/langchain-aws-dev/langchain-aws/libs/aws/langchain_aws/chat_models/bedrock_converse.py", line 682, in _messages_to_bedrock
messages = merge_message_runs(messages)
....
File "/Users/pijain/Library/Caches/pypoetry/virtualenvs/langchain-aws-eH7P7gjZ-py3.10/lib/python3.10/site-packages/langchain_core/utils/_merge.py", line 59, in merge_dicts
merged[right_k] = merge_dicts(merged[right_k], right_v)
File "/Users/pijain/Library/Caches/pypoetry/virtualenvs/langchain-aws-eH7P7gjZ-py3.10/lib/python3.10/site-packages/langchain_core/utils/_merge.py", line 65, in merge_dicts
raise TypeError(
TypeError: Additional kwargs key latencyMs already exists in left dict and value has unsupported type <class 'int'>. |
Seems like we will need a change in this function, to update the langchain-aws/libs/aws/langchain_aws/chat_models/bedrock_converse.py Lines 720 to 731 in adcfc34
Here is a simplified solution, however we might need to handle other keys that might cause issue while merging messages as well. response["metrics"]["latencyMs"] = [response["metrics"]["latencyMs"]] |
Thank you for having a look at this @3coins! Would you happen to know more or less when this would be fixed? |
I just faced similar error with ChatBedrockConverse: Additional kwargs key latencyMs already exists in left dict and value has unsupported type <class 'decimal.Decimal'>. In this case it's not |
Requirements:
I was developing a multi-agent workflow using Langchain and Langgraph.
One of my requirement was that the LLMs had to be provided by AWS Bedrock.
However, I noticed an issue with ChatBedrockConverse, where the invocation stops due to an issue with merging dictionaries.
As I was debugging the code, I replace my LLM with one from OpenAI and that fixed the issue I had., however, since I have the stated requirement , this is not only not a solution, but seems to identify a problem in langchain-aws specifically.
Code used:
The graph is as below:
As you can see, if you choose to use ChatOpenAI, the code will execute smoothly, however, when you change to ChatBerockConverse, the invocation breaks.
When the graph is invoked, the architect successfully call the Tools worker. However, when the architect receives the tool call output, it breaks. The output was the following:
The text was updated successfully, but these errors were encountered: