Do I use metadata of Documents for structured Data? #2726
Replies: 1 comment
-
🤖 Hello, Yes, you can use the Metadata property of the Document Class in LangChainJS to store and vectorize structured data in a Weaviate Vector Store. The WeaviateStore.fromTexts method accepts an array of texts and an array of metadata objects. These metadata objects are then stored in the Weaviate Vector Store along with the corresponding texts. The equivalence to the Weaviate Class you've configured depends on the structure of the metadata you're storing. If the keys in your metadata objects match the properties of your Weaviate Class, then they should be equivalent. Here's an example of how you can use the WeaviateStore.fromTexts method: await WeaviateStore.fromTexts(
["hello world", "hi there", "how are you", "bye now"],
[{ foo: "bar" }, { foo: "baz" }, { foo: "qux" }, { foo: "bar" }],
new OpenAIEmbeddings(),
{
client,
indexName: "Test",
textKey: "text",
metadataKeys: ["foo"],
}
); In this example, the metadata objects You can find more details in the examples/src/indexes/vector_stores/weaviate_fromTexts.ts and langchain/src/document.ts files in the LangChainJS repository. I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I hope u can help me with the following Question. :)
I want to use a Weaviate Vector Store to store data and vectorize it. Now I have data in a structured format (JSON) like this:
{
title: "",
description: "",
color: "",
url: ""
...
}
I have seen that u have to use Documents to store them with the function addDocuments(Documents[]), but I am not sure how to do that. Before I used the page content to store the Data as a string, but in Weaviate I have created a Class, where I configured, which attributes to vectorize and which not. So I thought, I will use the Metadata property of the Document Class, but I am not sure, that this will be equivalent to the Weaviate Class. Hope u can help me out to clarify that. :)
Beta Was this translation helpful? Give feedback.
All reactions