跳到主要內容

Jupyter Notebook (Jupyter 筆記本)

Jupyter Notebook (以前稱為 IPython Notebook) 是一個基於 Web 的互動式運算環境,用於建立筆記本文件。

本筆記本涵蓋如何將 Jupyter notebook (.ipynb) 中的資料載入到 LangChain 適合使用的格式。

from langchain_community.document_loaders import NotebookLoader
API 參考文檔:NotebookLoader
loader = NotebookLoader(
"example_data/notebook.ipynb",
include_outputs=True,
max_output_length=20,
remove_newline=True,
)

NotebookLoader.load().ipynb 筆記本檔案載入到 Document 物件中。

參數 (Parameters):

  • include_outputs (bool):是否在結果文件中包含儲存格輸出 (預設值為 False)。
  • max_output_length (int):從每個儲存格輸出中包含的最大字元數 (預設值為 10)。
  • remove_newline (bool):是否從儲存格來源和輸出中移除換行字元 (預設值為 False)。
  • traceback (bool):是否包含完整的回溯資訊 (預設值為 False)。
loader.load()
[Document(page_content='\'markdown\' cell: \'[\'# Notebook\', \'\', \'This notebook covers how to load data from an .html notebook into a format suitable by LangChain.\']\'\n\n \'code\' cell: \'[\'from langchain_community.document_loaders import NotebookLoader\']\'\n\n \'code\' cell: \'[\'loader = NotebookLoader("example_data/notebook.html")\']\'\n\n \'markdown\' cell: \'[\'`NotebookLoader.load()` loads the `.html` 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.html'})]

此頁面是否有幫助? (Was this page helpful?)