Find answers from the community

Updated 3 months ago

Langchain

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