Skip to main content

llama-index readers box integration

Project description

LlamaIndex: Box Readers

This open-source integration brings the capabilities of Box.com to the LLama-Index, empowering developers building Retrieval Augmented Generation (RAG) and other LLM applications.

This README will guide you through installation, usage, and explore the functionalities of each reader.

Installation

pip install llama-index-readers-box

Available readers

We provide multiple readers, including:

  • Box Reader - Implementation of the SimpleReader interface to read files from Box.
  • Box Text Extraction - Uses Box text representation to extract text from document.
  • Box AI Prompt - Uses Box AI to extract context from documents
  • Box AI Extraction - Uses Box AI to extract structured data from documents

[!IMPORTANT] Box AI features are only available to E+ customers.

Authentication

Client credential gran (CCG)

Create a new application in the Box Developer Console and generate a new client ID and client secret. Create a .env file with the following content:

# CCG settings
BOX_CLIENT_ID = YOUR_CLIENT_ID
BOX_CLIENT_SECRET = YOUR_CLIENT_SECRET

# Common Settings
BOX_ENTERPRISE_ID = YOUR_BOX_ENTERPRISE_ID
BOX_USER_ID = YOUR_BOX_USER_ID (optional)

By default the CCG client will use a service account associated with the application. Depending on how the files are shared, the service account may not have access to all the files.

If you want to use a different user, you can specify the user ID in the .env file. In this case make sure your application can impersonate and/or generate user tokens in the scope.

Checkout this guide for more information on how to setup the CCG: Box CCG Guide

JSON web tokens (JWT)

Create a new application in the Box Developer Console and generate a new .config.json file. Create a .env file with the following content:

# Common settings
BOX_ENTERPRISE_ID = 877840855
BOX_USER_ID = 18622116055

# JWT Settings
JWT_CONFIG_PATH = /path/to/your/.config.json

By default the JWT client will use a service account associated with the application. Depending on how the files are shared, the service account may not have access to all the files.

If you want to use a different user, you can specify the user ID in the .env file. In this case make sure your application can impersonate and/or generate user tokens in the scope.

Checkout this guide for more information on how to setup the JWT: Box JWT Guide

[!WARNING] The JWT authentication requires extra dependencies in the SDK. You can install them by running:

pip install "box-sdk-gen[jwt]"

Box Client

To work with the box readers, you will need to provide a Box Client. The Box Client can be created using either the Client Credential Grant (CCG), JSON Web Tokens (JWT), OAuth 2.0, and developer token.

Using CCG authentication

from box_sdk_gen import CCGConfig, BoxCCGAuth, BoxClient

config = CCGConfig(
    client_id="your_client_id",
    client_secret="your_client_secret",
    enterprise_id="your_enterprise_id",
    user_id="your_ccg_user_id",  # Optional
)
auth = BoxCCGAuth(config)
if config.user_id:
    auth.with_user_subject(config.user_id)
client = BoxClient(auth)

reader = BoxReader(box_client=client)

Using JWT authentication

from box_sdk_gen import JWTConfig, BoxJWTAuth, BoxClient

# Using manual configuration
config = JWTConfig(
    client_id="YOUR_BOX_CLIENT_ID",
    client_secret="YOUR_BOX_CLIENT_SECRET",
    jwt_key_id="YOUR_BOX_JWT_KEY_ID",
    private_key="YOUR_BOX_PRIVATE_KEY",
    private_key_passphrase="YOUR_BOX_PRIVATE_KEY_PASSPHRASE",
    enterprise_id="YOUR_BOX_ENTERPRISE_ID",
    user_id="YOUR_BOX_USER_ID",
)

# Using configuration file
config = JWTConfig.from_config_file("path/to/your/.config.json")


user_id = "1234"
if user_id:
    config.user_id = user_id
    config.enterprise_id = None
auth = BoxJWTAuth(config)
client = BoxClient(auth)

reader = BoxReader(box_client=client)

Author

Box-Community This is an open source reader, contributions are welcome.

This loader is designed to be used as a way to load data into LlamaIndex.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_readers_box-0.1.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

llama_index_readers_box-0.1.0-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_readers_box-0.1.0.tar.gz.

File metadata

  • Download URL: llama_index_readers_box-0.1.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1023-azure

File hashes

Hashes for llama_index_readers_box-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44a5931a2eb0d874dad87e1e632c2549fd1dd8ed410e2ffbe034fc3b4100d77c
MD5 f5dd2de5c820f9a94b0e2e43978d0209
BLAKE2b-256 fc79b1dc8ad3871aaec3bc9632de0edecc1c90e3f1039912896ab3f2de4092a9

See more details on using hashes here.

File details

Details for the file llama_index_readers_box-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_readers_box-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18ab1e66b1c74d45b94e95df545704acb0e4ebc5cbdc9f76dc68eed6572807f8
MD5 5611dd717d262a14b1fc6e59a6c9a8e5
BLAKE2b-256 c938914d76ec6887750471884a1f51d291fe19f82b789f3bd2f7aa03190f5bb8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page