|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Outline Document Loader\n", |
| 8 | + "\n", |
| 9 | + ">[Outline](https://www.getoutline.com/) is an open-source collaborative knowledge base platform designed for team information sharing.\n", |
| 10 | + "\n", |
| 11 | + "This notebook shows how to obtain langchain Documents from your Outline collections." |
| 12 | + ] |
| 13 | + }, |
| 14 | + { |
| 15 | + "cell_type": "markdown", |
| 16 | + "metadata": {}, |
| 17 | + "source": [ |
| 18 | + "## Overview\n", |
| 19 | + "The [Outline Document Loader](https://github.com/10Pines/langchain-outline) can be used to load Outline collections as LangChain Documents for integration into Retrieval-Augmented Generation (RAG) workflows.\n", |
| 20 | + "\n", |
| 21 | + "This example demonstrates:\n", |
| 22 | + "\n", |
| 23 | + "* Setting up a Document Loader to load all documents from an Outline instance." |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "markdown", |
| 28 | + "metadata": {}, |
| 29 | + "source": [ |
| 30 | + "### Setup\n", |
| 31 | + "Before starting, ensure you have the following environment variables set:\n", |
| 32 | + "\n", |
| 33 | + "* OUTLINE_API_KEY: Your API key for authenticating with your Outline instance (https://www.getoutline.com/developers#section/Authentication).\n", |
| 34 | + "* OUTLINE_INSTANCE_URL: The URL (including protocol) of your Outline instance." |
| 35 | + ] |
| 36 | + }, |
| 37 | + { |
| 38 | + "cell_type": "code", |
| 39 | + "execution_count": null, |
| 40 | + "metadata": {}, |
| 41 | + "outputs": [], |
| 42 | + "source": [ |
| 43 | + "import os\n", |
| 44 | + "\n", |
| 45 | + "os.environ[\"OUTLINE_API_KEY\"] = \"ol_api_xyz123\"\n", |
| 46 | + "os.environ[\"OUTLINE_INSTANCE_URL\"] = \"https://app.getoutline.com\"" |
| 47 | + ] |
| 48 | + }, |
| 49 | + { |
| 50 | + "cell_type": "markdown", |
| 51 | + "metadata": {}, |
| 52 | + "source": [ |
| 53 | + "## Initialization\n", |
| 54 | + "To initialize the OutlineLoader, you need the following parameters:\n", |
| 55 | + "\n", |
| 56 | + "* outline_base_url: The URL of your outline instance (or it will be taken from the environment variable).\n", |
| 57 | + "* outline_api_key: Your API key for authenticating with your Outline instance (or it will be taken from the environment variable).\n", |
| 58 | + "* outline_collection_id_list: List of collection ids to be retrieved. If None all will be retrieved.\n", |
| 59 | + "* page_size: Because the Outline API uses paginated results you can configure how many results (documents) per page will be retrieved per API request. If this is not specified a default will be used." |
| 60 | + ] |
| 61 | + }, |
| 62 | + { |
| 63 | + "cell_type": "markdown", |
| 64 | + "metadata": {}, |
| 65 | + "source": [ |
| 66 | + "## Instantiation" |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "code", |
| 71 | + "execution_count": null, |
| 72 | + "metadata": {}, |
| 73 | + "outputs": [], |
| 74 | + "source": [ |
| 75 | + "# Option 1: Using environment variables (ensure they are set)\n", |
| 76 | + "from langchain_outline.document_loaders.outline import OutlineLoader\n", |
| 77 | + "\n", |
| 78 | + "loader = OutlineLoader()\n", |
| 79 | + "\n", |
| 80 | + "# Option 2: Passing parameters directly\n", |
| 81 | + "loader = OutlineLoader(\n", |
| 82 | + " outline_base_url=\"YOUR_OUTLINE_URL\", outline_api_key=\"YOUR_API_KEY\"\n", |
| 83 | + ")" |
| 84 | + ] |
| 85 | + }, |
| 86 | + { |
| 87 | + "cell_type": "markdown", |
| 88 | + "metadata": {}, |
| 89 | + "source": [ |
| 90 | + "## Load\n", |
| 91 | + "To load and return all documents available in the Outline instance" |
| 92 | + ] |
| 93 | + }, |
| 94 | + { |
| 95 | + "cell_type": "code", |
| 96 | + "execution_count": null, |
| 97 | + "metadata": {}, |
| 98 | + "outputs": [], |
| 99 | + "source": [ |
| 100 | + "loader.load()" |
| 101 | + ] |
| 102 | + }, |
| 103 | + { |
| 104 | + "cell_type": "markdown", |
| 105 | + "metadata": {}, |
| 106 | + "source": [ |
| 107 | + "## Lazy Load\n", |
| 108 | + "The lazy_load method allows you to iteratively load documents from the Outline collection, yielding each document as it is fetched:" |
| 109 | + ] |
| 110 | + }, |
| 111 | + { |
| 112 | + "cell_type": "code", |
| 113 | + "execution_count": null, |
| 114 | + "metadata": {}, |
| 115 | + "outputs": [], |
| 116 | + "source": [ |
| 117 | + "loader.lazy_load()" |
| 118 | + ] |
| 119 | + }, |
| 120 | + { |
| 121 | + "cell_type": "markdown", |
| 122 | + "metadata": {}, |
| 123 | + "source": [ |
| 124 | + "## API reference\n", |
| 125 | + "\n", |
| 126 | + "For detailed documentation of all `Outline` features and configurations head to the API reference: https://www.getoutline.com/developers" |
| 127 | + ] |
| 128 | + } |
| 129 | + ], |
| 130 | + "metadata": { |
| 131 | + "kernelspec": { |
| 132 | + "display_name": ".venv", |
| 133 | + "language": "python", |
| 134 | + "name": "python3" |
| 135 | + }, |
| 136 | + "language_info": { |
| 137 | + "codemirror_mode": { |
| 138 | + "name": "ipython", |
| 139 | + "version": 3 |
| 140 | + }, |
| 141 | + "file_extension": ".py", |
| 142 | + "mimetype": "text/x-python", |
| 143 | + "name": "python", |
| 144 | + "nbconvert_exporter": "python", |
| 145 | + "pygments_lexer": "ipython3", |
| 146 | + "version": "3.11.9" |
| 147 | + } |
| 148 | + }, |
| 149 | + "nbformat": 4, |
| 150 | + "nbformat_minor": 2 |
| 151 | +} |
0 commit comments