Agent Invoke method #24292
Replies: 1 comment 1 reply
-
Hello @Harish-ilink! I'm here to help you with any bugs, questions, or contributions you may have. Let's work together to solve this issue! To resolve the 'AttributeError: 'dict' object has no attribute 'id'' error when calling the Here's an example of how to structure the input correctly: from langchain_core.messages import HumanMessage
# Example of a correct input structure for the invoke method
input_data = [
HumanMessage(content="Hello, how are you?")
]
# Assuming `agent` is an instance of the agent class
response = agent.invoke(input=input_data, config=config) Ensure that each dictionary in the list has the correct keys and values that the Additionally, if you are mocking responses for testing purposes, ensure that the mock objects are correctly structured. For example, in the provided test case for the OCI Generative AI LLM service, the mock response is structured using a class MockResponseDict(dict):
def __getattr__(self, val):
return self[val]
# Example of a mocked response
response = MockResponseDict(
{
"status": 200,
"data": MockResponseDict(
{
"chat_response": MockResponseDict(
{
"text": "Assistant chat reply.",
"finish_reason": "completed",
}
),
"model_id": "cohere.command-r-16k",
"model_version": "1.0.0",
}
),
"request_id": "1234567890",
"headers": MockResponseDict(
{
"content-length": "123",
}
),
}
) By ensuring that both your input data and any mock responses are correctly structured, you can avoid the 'AttributeError: 'dict' object has no attribute 'id'' error [1][2][3]. |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
Im trying to call invoke method insteam of streaming my bots response.But I was getting error .I have tried aiinvoke() method also.But Im ending up in same error.
File "/usr/local/lib/python3.11/site-packages/langgraph/channels/binop.py", line 58, in update
2024-07-16 10:55:18 self.value = self.operator(self.value, value)
2024-07-16 10:55:18 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-16 10:55:18 File "/usr/local/lib/python3.11/site-packages/langgraph/graph/message.py", line 22, in add_messages
2024-07-16 10:55:18 if m.id is None:
2024-07-16 10:55:18 ^^^^
2024-07-16 10:55:18 AttributeError: 'dict' object has no attribute 'id'
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found:
Beta Was this translation helpful? Give feedback.
All reactions