Skip to content

Commit 49f5021

Browse files
authored
Update Google Drive docs with GetFileTreeStructure tool (#182)
* document GetFileTreeStructure tool * examples for getting Drive file tree structure
1 parent 535d932 commit 49f5021

File tree

5 files changed

+140
-0
lines changed

5 files changed

+140
-0
lines changed

pages/toolkits/productivity/google/drive.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,42 @@ List documents in the user's Google Drive. Excludes documents that are in the tr
8080
- **`supports_all_drives`** _(bool, optional)_ Whether the requesting application supports both My Drives and shared drives. Defaults to `False`.
8181
- **`limit`** _(int, optional)_ The number of documents to list. Defaults to `50`.
8282

83+
## GetFileTreeStructure
84+
85+
<br />
86+
<TabbedCodeBlock
87+
tabs={[
88+
{
89+
label: "Call the Tool with User Authorization",
90+
content: {
91+
Python: [
92+
"/examples/integrations/toolkits/google/drive/get_file_tree_structure_example_call_tool.py",
93+
],
94+
JavaScript: ["/examples/integrations/toolkits/google/drive/get_file_tree_structure_example_call_tool.js"],
95+
},
96+
},
97+
{
98+
label: "Execute the Tool with OpenAI",
99+
content: {
100+
Python: [
101+
"/examples/integrations/toolkits/google/drive/get_file_tree_structure_example_llm_oai.py",
102+
],
103+
JavaScript: ["/examples/integrations/toolkits/google/drive/get_file_tree_structure_example_llm_oai.js"],
104+
},
105+
},
106+
]}
107+
/>
108+
109+
Get the file/folder tree structure of the user's Google Drive.
110+
111+
**Parameters**
112+
113+
- **`include_shared_drives`** _(bool, optional)_ Whether to include shared drives in the file tree structure. Defaults to False.
114+
- **`restrict_to_shared_drive_id`** _(str, optional)_ If provided, only include files from this shared drive in the file tree structure. Defaults to None, which will include files and folders from all drives.
115+
- **`include_organization_domain_documents`** _(bool, optional)_ Whether to include documents from the organization's domain. This is applicable to admin users who have permissions to view organization-wide documents in a Google Workspace account. Defaults to False.
116+
- **`order_by`** _(enum ([OrderBy](/toolkits/productivity/google/reference#orderby)), optional)_ Sort order. Defaults to listing the most recently modified documents first.
117+
- **`limit`** _(int, optional)_ The number of files and folders to list. Defaults to None, which will list all files and folders.
118+
83119
## Auth
84120

85121
The Arcade Drive toolkit uses the [Google auth provider](/home/auth-providers/google) to connect to users' Google accounts.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Arcade } from "@arcadeai/arcadejs";
2+
3+
const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable
4+
5+
const USER_ID = "[email protected]";
6+
const TOOL_NAME = "Google.GetFileTreeStructure";
7+
8+
// Start the authorization process
9+
const authResponse = await client.tools.authorize({
10+
tool_name: TOOL_NAME,
11+
user_id: USER_ID,
12+
});
13+
14+
if (authResponse.status !== "completed") {
15+
console.log(`Click this link to authorize: ${authResponse.url}`);
16+
}
17+
18+
// Wait for the authorization to complete
19+
await client.auth.waitForCompletion(authResponse);
20+
21+
const toolInput = {
22+
include_shared_drives: true,
23+
limit: 10,
24+
};
25+
26+
const response = await client.tools.execute({
27+
tool_name: TOOL_NAME,
28+
input: toolInput,
29+
user_id: USER_ID,
30+
});
31+
32+
console.log(response);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from arcadepy import Arcade
2+
3+
client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable
4+
5+
USER_ID = "[email protected]"
6+
TOOL_NAME = "Google.GetFileTreeStructure"
7+
8+
auth_response = client.tools.authorize(
9+
tool_name=TOOL_NAME,
10+
user_id=USER_ID,
11+
)
12+
13+
if auth_response.status != "completed":
14+
print(f"Click this link to authorize: {auth_response.url}")
15+
16+
# Wait for the authorization to complete
17+
client.auth.wait_for_completion(auth_response)
18+
19+
tool_input = {
20+
"include_shared_drives": True,
21+
"limit": 10,
22+
}
23+
24+
response = client.tools.execute(
25+
tool_name=TOOL_NAME,
26+
input=tool_input,
27+
user_id=USER_ID,
28+
)
29+
print(response)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import OpenAI from 'openai';
2+
3+
const USER_ID = "[email protected]";
4+
const PROMPT = "Get a file tree structure of my Google Drive, including shared drives.";
5+
const TOOL_NAME = "Google.GetFileTreeStructure";
6+
7+
const client = new OpenAI({
8+
baseURL: 'https://api.arcade.dev',
9+
apiKey: process.env.ARCADE_API_KEY
10+
});
11+
12+
const response = await client.chat.completions.create({
13+
messages: [
14+
{ role: 'user', content: PROMPT }
15+
],
16+
model: 'gpt-4o-mini',
17+
user: USER_ID,
18+
tools: [TOOL_NAME],
19+
tool_choice: 'generate'
20+
});
21+
22+
console.log(response.choices[0].message.content);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
from openai import OpenAI
3+
4+
USER_ID = "[email protected]"
5+
PROMPT = "Get a file tree structure of my Google Drive, including shared drives."
6+
TOOL_NAME = "Google.GetFileTreeStructure"
7+
8+
client = OpenAI(
9+
base_url="https://api.arcade.dev", api_key=os.environ.get("ARCADE_API_KEY")
10+
)
11+
12+
response = client.chat.completions.create(
13+
messages=[
14+
{"role": "user", "content": PROMPT},
15+
],
16+
model="gpt-4o-mini",
17+
user=USER_ID,
18+
tools=[TOOL_NAME],
19+
tool_choice="generate",
20+
)
21+
print(response.choices[0].message.content)

0 commit comments

Comments
 (0)