Reference
@chloejs/ core/ tools/ drive
Finding files in one part of Google Drive, and reading one as text.
The tools over driveService.ts: finding files in the part of Drive an agent is bound to, reading one as text, and downloading one as it is. The binding lives in the agent's config, and the model chooses only the words to look for.
import * as drive from "@chloejs/core/tools/drive";
tools: { driveSearchFiles: drive.searchFiles({ search }), driveReadFile: drive.readFile({ search }) }downloadFilereadFilesearchFiles
downloadFilefunction
export function downloadFile({ search = "", what = "Drive", agent }: Options & { agent: string })Makes a tool that lets the model download one Drive file as it is (a PDF, a picture) and get the full path it was saved at, to hand to a script. It goes in the agent's received files, with what people sent it.
The model passes a Drive link or a file id. With a search, only a file
drive.searchFiles listed with it; without one, any file the account can open.
agent: the agent's id, whose received files it goes in. Required.
Needs the Google connection.
readFilefunction
export function readFile({ search = "", what = "Drive" }: Options = {})Makes a tool that lets the model read one Drive file as text: a Google Doc, Sheet or Slides, or a plain text file. Other files (such as images) are refused. A very long file is cut short.
The model can read only a file that drive.searchFiles has already listed
with the same search, so give both tools the same search.
Needs the Google connection.
searchFilesfunction
export function searchFiles({ search = "", what = "Drive" }: Options = {})Makes a tool that lets the model find files in Google Drive, newest first, or by words in their name or text. Files in the trash are left out.
search sets which files the model can see, and the model cannot change
it. The model chooses only the words to look for and how many files (up to
50, default 20).
Give it the same search as the agent's drive.readFile. Needs the Google
connection.