Google Drive Tools
credentials.json
file downloaded to your local machine.
google-api
extra. Since our examples also use
openai
, install it as well:
Note: If you have been usingautogen
orag2
, all you need to do is upgrade it using:orasautogen
, andag2
are aliases for the same PyPI package.
client_secret_file
: The path to the client secret file, which you can
download from the Google Cloud Console. This file contains the necessary
credentials to authenticate the user with Google services. -
token_file
: The path to a file that will store the access token. After
the first run of the script, this token will be saved and used for
subsequent authentications, avoiding the need for repeated login
processes. - provider
(GoogleCredentialsLocalProvider
): The provider
is responsible for managing the authentication process. - credentials
:
This variable stores the credentials object, which will be used by the
system to authenticate the user and gain access to their Google Drive
resources.
Note: The first execution opens a Google Authentication page in your browser.
GoogleDriveToolkit
class provides a set of predefined tools for
seamless interaction with Google Drive. These tools include: -
list_drive_files_and_folders
: Allows the user to list all files and
folders in their Google Drive. - download_file_from_drive
: Enables
downloading files directly from Google Drive to a specified local
folder.
Once the tool map is registered with the agent using register_for_llm
,
the agent becomes capable of suggesting these tool calls.
GoogleDriveToolkit
based on
your specific requirements. By subclassing GoogleDriveToolkit
, you can
modify the toolset available to your agent.
For example: - Add custom tools: You can introduce new tools, like
list_docs
, to specifically retrieve document files from a folder. -
Remove existing tools: You can eliminate unnecessary tools, such as
list_drive_files_and_folders
, to streamline functionality and focus on
relevant features.