Accepted message formats
LangChain modules acceptMessageLikeRepresentation, which is defined as:
{ role: "user", content: "Hello world!" }), tuples, and plain strings (which are converted to HumanMessage objects).
If a module receives a value outside of one of these formats, you will receive an error:
Troubleshooting
To resolve this error:- Ensure proper format: All inputs to chat models must be an array of LangChain message classes or a supported message-like format
- Verify no unintended stringification or transformation occurs to your messages
- Examine the error’s stack trace and add logging statements to inspect message objects before they’re passed to the model