Initial work to add Astra DB Chat History
DO NOT MERGE
This PR is the initial work to integrate https://python.langchain.com/docs/integrations/memory/astradb_chat_message_history/ with the chat history components of langflow. WIP.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| langflow | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 9, 2024 11:21pm |
Hey @erichare How are you?
I was thinking here. LangChain components are composable while if we want to pass the info from a ChatInput component, it will be used outside of a Runnable.
In Langflow we have a Message History component that just gets messages and the ChatInput automatically saves message if the user provides a Session ID.
My question to you is: What would be the best way in your opinion, to have a Component that does both, and if not, what should we change to make that work?
Hi @ogabrielluiz . I had the exact same question really. I felt like i was re-inventing the wheel by making this, but i wasnt sure if it was kosher for example to have a parameter that basically dictates whether it is going into Astra DB or not - particularly because we do require auth info if thats the case.
I'll admit i'm so new to langflow and how the chat history operates that I don't have a strong opinion on the best solution, i'd lean on you and any others to make a recommendation and happily adapt the PR recordingly. Maybe its worth setting up a time to have a quick discussion with whomever would be the right people to help guide that decision?
Thanks so much for the feedback by the way! definitely just wanted to make a first pass to kinda get my feet wet and get the discussion started, but i had a feeling this probably isn't the optimal way to go about it.
Hey @erichare
We've decided to add two components just like the Vector Store.
One component should instantiate the AstraDBChatMessageHistory and add messages to it based on the sender (User-> human, Machine -> AI) from the Chat Input or the Chat Output. It should be called Astra DB Message Writer.
And another that might have some filtering capabilities and should be called Astra DB Message Reader.
What do you think?
Hey @erichare
We've decided to add two components just like the Vector Store.
One component should instantiate the AstraDBChatMessageHistory and add messages to it based on the
sender(User-> human, Machine -> AI) from the Chat Input or the Chat Output. It should be calledAstra DB Message Writer. And another that might have some filtering capabilities and should be calledAstra DB Message Reader.What do you think?
@ogabrielluiz I think that sounds great! Basically a reader and a writer component for Astra. Should i take a first stab at this? Anyone that i should collaborate with? Thank you!!
Hey @erichare We've decided to add two components just like the Vector Store. One component should instantiate the AstraDBChatMessageHistory and add messages to it based on the
sender(User-> human, Machine -> AI) from the Chat Input or the Chat Output. It should be calledAstra DB Message Writer. And another that might have some filtering capabilities and should be calledAstra DB Message Reader. What do you think?@ogabrielluiz I think that sounds great! Basically a reader and a writer component for Astra. Should i take a first stab at this? Anyone that i should collaborate with? Thank you!!
Me! hahaha
This should be pretty straightforward. Remember two things: field_type and required are not used in the build_configand are defined by the build method signature, and try to follow the signature of other components like the vector store (e.g. use input_value as the name of the main input to your component) because we plan to use that later on.
Good display_name and description always help.
Hey @erichare We've decided to add two components just like the Vector Store. One component should instantiate the AstraDBChatMessageHistory and add messages to it based on the
sender(User-> human, Machine -> AI) from the Chat Input or the Chat Output. It should be calledAstra DB Message Writer. And another that might have some filtering capabilities and should be calledAstra DB Message Reader. What do you think?@ogabrielluiz I think that sounds great! Basically a reader and a writer component for Astra. Should i take a first stab at this? Anyone that i should collaborate with? Thank you!!
Me! hahaha
This should be pretty straightforward. Remember two things:
field_typeandrequiredare not used in thebuild_configand are defined by thebuildmethod signature, and try to follow the signature of other components like the vector store (e.g. useinput_valueas the name of the main input to your component) because we plan to use that later on.Good
display_nameanddescriptionalways help.
hahaha awesome 😄 thanks @ogabrielluiz . Just a process question here, do you want me to take a first stab at this, or you / someone else on the langflow side? Just want to double check haha
Hey @erichare We've decided to add two components just like the Vector Store. One component should instantiate the AstraDBChatMessageHistory and add messages to it based on the
sender(User-> human, Machine -> AI) from the Chat Input or the Chat Output. It should be calledAstra DB Message Writer. And another that might have some filtering capabilities and should be calledAstra DB Message Reader. What do you think?@ogabrielluiz I think that sounds great! Basically a reader and a writer component for Astra. Should i take a first stab at this? Anyone that i should collaborate with? Thank you!!
Me! hahaha This should be pretty straightforward. Remember two things:
field_typeandrequiredare not used in thebuild_configand are defined by thebuildmethod signature, and try to follow the signature of other components like the vector store (e.g. useinput_valueas the name of the main input to your component) because we plan to use that later on. Gooddisplay_nameanddescriptionalways help.hahaha awesome 😄 thanks @ogabrielluiz . Just a process question here, do you want me to take a first stab at this, or you / someone else on the langflow side? Just want to double check haha
I'm writing a base class for message history. Maybe you could take a stab at it for Astra DB.
I'll get it to the dev branch shortly, then you can import it and we can create components based on a single abstraction.