Find answers from the community

Updated 6 months ago

Langchain

At a glance

The community member is asking if there is a way to add metadata, such as timestamp, to the HumanMessage and AIMessage blocks that are persisted to memory when using agent_chain.run() in LangChain. The comments suggest that while there are additional kwargs on the message class, the community members are unsure if adding metadata there would cause errors. They also mention that having access to a message UUID could help amend the stored messages with metadata after the agent finishes generation. However, the community members note that when calling the agent, they cannot explicitly define the memory, as it has to be accessed again, and suggest creating a parallel memory as a potential solution.

Useful resources
For a single inference, using agent_chain.run( ... ) in langchain, for the HumanMessage + AIMessage message blocks being persisted to memory, is there a way to add metadata to those?

By metadata, I mean timestamp, etc.

Any pointers?
L
H
4 comments
Not sure. I see additional kwargs on their message class, but I have a feeling it might cause errors to put things in there. Worth a shot though!

https://github.com/hwchase17/langchain/blob/0ed2da70200ada39f5319f604b4c5248bc98e81b/langchain/schema/messages.py#L67
Lol. Doesn’t help. I tried where these kwargs go, or even the metadata param on the ‘run’ method, but no luck. They should provide a way to add metadata to each (Human + AI) message pair when storing to memory. Could help a lot.
Generally speaking even having access to message UUID could help so we can amend the one stored with metadata after the agent finishes generation.
When doing a call through agent, I can’t explicitly define memory. As it has to be accessed again. Maybe I can create a parallel memory.
Add a reply
Sign up and join the conversation on Discord