LangChainOneDriveFileLoader
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 setInstallation
Install the published package using pip or uv.
pip install sinapsis_langchain_readers==1.0.0uv pip install sinapsis_langchain_readers==1.0.0uv add sinapsis_langchain_readers==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
ID of the file in OneDrive (alternative to file_path).
Optional
Default: null
The OneDrive drive ID.
Required
Default: null
Optional
Default: null
Path to the file in OneDrive (alternative to file_id).
Optional
Default: null
Path to the saved authentication token.
Optional
Default: "/home/runner/.credentials/o365_token.txt"
Whether to authenticate with a saved token.
Optional
Default: false
Whether to add document as text packet or not.
Optional
Default: false
Configuration example
Example from the Python docstring:
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.txtShow schema-based configuration skeleton
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
sinapsis_langchain_readers.templates.base_static_loader.BaseStaticLoaderEnvironment variables
Environment definitions belong to their canonical Python modules.
No directly related environment variables listed.