Deserializing LangChain messages

174 views Asked by At

LangChain's BaseMessage has a function toJSON that returns a Serialized.

Once I have a list of BaseMessages, I can use toJSON to serialize them, but how can I later deserialize them?

const messages = [
  new HumanMessage("hello"),
  new AIMessage("foo"),
  new HumanMessage("bar"),
  new AIMessage("baz"),
];

const serialized = messages.map((message) => message.toJSON());

const deserialized = ???
0

There are 0 answers