Chainlit / cookbook

Chainlit's cookbook repo
https://github.com/Chainlit/chainlit
726 stars 270 forks source link

Document prompt requires documents to have metadata variables: ['source']. Received document with missing metadata: ['source']. #12

Closed echoopen closed 1 year ago

echoopen commented 1 year ago

I'm very sorry, but I'm having this problem with the pinecone example: "Document prompt requires documents to have metadata variables: ['source']. Received document with missing metadata: ['source']."

willydouhard commented 1 year ago

Don't be sorry! It looks like the documents you embedded and persisted in your pinecone miss an attribute. If you use the pdf-qa example does it work? (it is the same as the pinecone example but it also creates the vectors from the uploaded pdf)

echoopen commented 1 year ago

The pdf example works, but the pdf example has this code: docs = text_splitter.splitdocuments (documents) for i, doc in enumerate(docs). doc.metadata["source"] = f "source{i}" return docs

But I use DirectoryLoader to load the txt text into docs, after using the above code, still report this error, if it is convenient, convenient to give me a simple DirectoryLoader will be stored in the vector Pinecone example? Mine is docsearch = Pinecone.from_texts(split_docs, embeddings, index_name=index_name)

willydouhard commented 1 year ago

I found this example showing how to useDirectoryLoader with sources.