Back to Llama Index

Setup Box Client

llama-index-integrations/tools/llama-index-tools-box/examples/box_search.ipynb

0.14.211.5 KB
Original Source
python
# Setup Box Client
from box_sdk_gen import DeveloperTokenConfig, BoxDeveloperTokenAuth, BoxClient

BOX_DEV_TOKEN = "your_box_dev_token"

config = DeveloperTokenConfig(BOX_DEV_TOKEN)
auth = BoxDeveloperTokenAuth(config)
box_client = BoxClient(auth)
python
import os
os.environ["OPENAI_API_KEY"] = "your-key"

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
python
# Import and initialize Box tool spec

from llama_index.tools.box import BoxSearchToolSpec

box_tool_spec = BoxSearchToolSpec(box_client)

# Create an agent with the Box tool spec
agent = FunctionAgent(
    tools=box_tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

answer = await agent.run("search all invoices")
print(answer)
I found the following invoices:

1. **Invoice-A5555.txt**
   - Size: 150 bytes
   - Created By: RB Admin
   - Created At: 2024-04-30 06:22:18

2. **Invoice-Q2468.txt**
   - Size: 176 bytes
   - Created By: RB Admin
   - Created At: 2024-04-30 06:22:19

3. **Invoice-B1234.txt**
   - Size: 168 bytes
   - Created By: RB Admin
   - Created At: 2024-04-30 06:22:15

4. **Invoice-Q8888.txt**
   - Size: 164 bytes
   - Created By: RB Admin
   - Created At: 2024-04-30 06:22:14

5. **Invoice-C9876.txt**
   - Size: 189 bytes
   - Created By: RB Admin
   - Created At: 2024-04-30 06:22:17

These are the invoices found in the search. Let me know if you need more information or assistance with these invoices.