Storing Chat History along with Image or Image Reference using LangChain JS #7075
Replies: 1 comment 1 reply
-
Hey @hemantchaudhari2006! 👋 I'm here to help you out with any questions or issues you have. Let's work together to solve this problem! To store image references alongside chat messages in DynamoDB using LangChain JS, you can utilize the Here's how you can modify your code to include image URLs in the chat history:
const message: StoredMessage = {
type: "chat",
data: {
content: "Here is an image",
role: "user",
additional_kwargs: {
imageUrl: `data:image/jpeg;base64,${base64String}`
}
}
};
By following these steps, you can store image references in DynamoDB alongside your chat messages, allowing you to retrieve and display both text and images when loading chat history [1]. |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
I am using below example from the link to store chat history in dynamodb using langchain JS.
https://js.langchain.com/docs/integrations/memory/dynamodb
It is working fine, but I found that it does not store anything about image which I attached with one of my question. It just stores text, not image url or reference.
Actually, I am storing my images in S3 and collecting data from there to convert to base64 as mentioned above. Chat is giving correct answer as well for the image. The only problem is, it does not store anything for image in dynamodb, only stores text (my question). I want to have image reference with the question in the database, so that I can load chat history later on along with image data.
System Info
yarn info langchain
platform lambda
Node version 18
Beta Was this translation helpful? Give feedback.
All reactions