Files
langchain/docs/modules/indexes/document_loaders/examples/notebook.ipynb
T
Zander ChaseandLeonid Ganeline aa38355999 Vwp/docs improved document loaders (#4006)
Huge thanks to @leo-gan for improving the document loaders notebooks

---------

Co-authored-by: Leonid Ganeline <leo.gan.57@gmail.com>
2023-05-02 15:24:53 -07:00

3.3 KiB

Notebook

This notebook covers how to load data from a Jupyter notebook (.ipynb) into a format suitable by LangChain.

In [1]:
from langchain.document_loaders import NotebookLoader
In [2]:
loader = NotebookLoader("example_data/notebook.ipynb", include_outputs=True, max_output_length=20, remove_newline=True)

NotebookLoader.load() loads the .ipynb notebook file into a Document object.

Parameters:

  • include_outputs (bool): whether to include cell outputs in the resulting document (default is False).
  • max_output_length (int): the maximum number of characters to include from each cell output (default is 10).
  • remove_newline (bool): whether to remove newline characters from the cell sources and outputs (default is False).
  • traceback (bool): whether to include full traceback (default is False).
In [3]:
loader.load()
Out [3]:
[Document(page_content='\'markdown\' cell: \'[\'# Notebook\', \'\', \'This notebook covers how to load data from an .ipynb notebook into a format suitable by LangChain.\']\'\n\n \'code\' cell: \'[\'from langchain.document_loaders import NotebookLoader\']\'\n\n \'code\' cell: \'[\'loader = NotebookLoader("example_data/notebook.ipynb")\']\'\n\n \'markdown\' cell: \'[\'`NotebookLoader.load()` loads the `.ipynb` notebook file into a `Document` object.\', \'\', \'**Parameters**:\', \'\', \'* `include_outputs` (bool): whether to include cell outputs in the resulting document (default is False).\', \'* `max_output_length` (int): the maximum number of characters to include from each cell output (default is 10).\', \'* `remove_newline` (bool): whether to remove newline characters from the cell sources and outputs (default is False).\', \'* `traceback` (bool): whether to include full traceback (default is False).\']\'\n\n \'code\' cell: \'[\'loader.load(include_outputs=True, max_output_length=20, remove_newline=True)\']\'\n\n', metadata={'source': 'example_data/notebook.ipynb'})]