Docs /Templates/ sinapsis_langchain_readers

LangChainOneDriveFileLoader

sinapsis_langchain_readersLangChaindocumentsdocument_loadingdynamicfiles

Python template · sinapsis_langchain_readers.templates.one_drive_file_loader

Overview

Template to load documents using Langchain OneDriveFileLoader module. The template loads a OneDrive file either as a Document object in the generic_data field of DataContainer of each string as a TextPacket if add_document_as_text_packet is set as True Instructions reference: https://python.langchain.com/docs/integrations/document_loaders/microsoft_onedrive/

Prerequisites *Configure an Microsoft Entra app: https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app *Configure a client secret *Add 'offline_access' and 'Files.Read.All' to the app scopes: https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-expose-web-apis *Find out your Drive ID by making a query and finding the 'id' field at https://developer.microsoft.com/en-us/graph/graph-explorer *Add the Entra client ID to 'O365_CLIENT_ID' environment variable *Add the client secret value to 'O365_CLIENT_SECRET' environment variable *Add your Drive ID to the config attributes

Usage *Add the information to query through 'file_path' or 'file_id' in the config *The first time OneDriveFileLoader is run, it will give a URL to visit. Follow the link and copy the URL of the site that appears after consenting to permissions. *This will save a token at ~/.credentials/o365_token.txt *After this, modify 'auth_with_token' attribute to True and add the 'token_path'

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis_langchain_readers==1.0.0
uv pip install sinapsis_langchain_readers==1.0.0
uv add sinapsis_langchain_readers==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

file_id

ID of the file in OneDrive (alternative to file_path).

str | None
Optional
Default: null
drive_idRequired

The OneDrive drive ID.

str
Required
Default: null
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
file_path

Path to the file in OneDrive (alternative to file_id).

str | None
Optional
Default: null
token_path

Path to the saved authentication token.

str
Optional
Default: "/home/runner/.credentials/o365_token.txt"
auth_with_token

Whether to authenticate with a saved token.

bool
Optional
Default: false
add_document_as_text_packet

Whether to add document as text packet or not.

bool
Optional
Default: false

Configuration example

Example from the Python docstring:

yaml
agent:
name: one_drive_file_loader
description: "One Drive File Loader example"

templates:

- template_name: InputTemplate
class_name: InputTemplate
attributes: {}

- template_name: LangChainOneDriveFileLoader
class_name: LangChainOneDriveFileLoader
template_input: InputTemplate
attributes:
    add_document_as_text_packet: false
    file_path: "/path/to/file.pdf"
    file_id: "file_id_from_onedrive"
    drive_id: drive_id
    auth_with_token: false
    token_path: /path/to/token.txt
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "LangChainOneDriveFileLoader"
    class_name: "LangChainOneDriveFileLoader"
    attributes:
      file_id: null
      drive_id: "<required>"
      file_path: null
      token_path: "/home/runner/.credentials/o365_token.txt"
      auth_with_token: false
      add_document_as_text_packet: false

Inheritance

Immediate parent: sinapsis_langchain_readers.templates.base_static_loader.BaseStaticLoader

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.