to_langchain_documents#

scikitplot.corpus.to_langchain_documents(documents)[source]#

Convert CorpusDocument instances to LangChain Document.

Parameters:
documentsSequence[CorpusDocument]

Source documents.

Returns:
list[langchain_core.documents.Document] or list[dict]

LangChain Document objects. Falls back to equivalent dicts if langchain_core is not installed.

Parameters:

documents (Sequence[Any])

Return type:

list[Any]

Notes

User note: These documents are directly usable with any LangChain retriever, chain, or agent:

from langchain.chains import RetrievalQA

lc_docs = to_langchain_documents(corpus_docs)
# Feed to vector store, retriever, etc.

Examples

>>> lc_docs = to_langchain_documents(corpus_docs)
>>> type(lc_docs[0]).__name__
'Document'