gpt-files
is a CLI tool for managing resources (file
, vector store
,
code
...etc) for OpenAI assistant with ease. It can be easily installed on
Linux, macOS, and Windows.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/hn12404988/gpt-files/main/install.sh)"
powershell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/hn12404988/gpt-files/main/install.ps1 | Invoke-Expression"
# Create a new assistant
gpt-files create-assistant -n my-assistant
# Upload a file to the assistant
gpt-files upload ./deno.json
# Upload all files of a directory to the assistant
gpt-files upload-dir ./reports
# List all files in the assistant
gpt-files list
To see all the available commands and options, please run --help
.
$ gpt-files --help
Options:
-h, --help - Show this help.
-V, --version - Show the version number for this program.
--verbose - Print verbose output (Default: false)
Commands:
# Assistant
create-assistant - Create a new assistant.
update-assistant <assistantId> - Update an assistant
del-assistant <assistantId> - Delete an assistant
assistant <assistantId> - Show the details of an assistant
assistants - List all assistants
# Vector Store
create-store <name> - Create a new vector store
del-store <vectorStoreId> - Delete a vector store
store <vectorStoreId> - Show the details of a vector store
stores - List all vector stores
# File
upload <filePath> - Upload a file to an assistant
upload-dir <dirPath> - Upload all files of a directory to an assistant
delete <fileId> - Detach a file from an assistant and delete it permanently
detach <fileId> - Detach a file from an assistant
file <fileId> - Show the details of a file
list - List all files attached to an assistant
files - List all files under your openai account
Environment variables:
OPENAI_API_KEY <value> - OpenAI api key (required)
OPENAI_ASSISTANT_ID <value> - OpenAI assistant id. Required for file operation commands
For each command, you can run --help
to see the available options like this.
$ gpt-files upload --help
Usage: gpt-files upload <filePath>
Description:
Upload a file to an assistant
Options:
-h, --help - Show this help.
--verbose - Print verbose output (Default: false)
-n, --file-name <name> - New filename to replace the original filename
-o, --overwrite - Overwrite if existed (Default: false)
-d, --destination <destination> - Upload to vector store or code interpreter. (Default: "file", Values: "file", "code")
-a, --assistant-id <assistantId> - If this option is provided, this is used as the assistant id instead of the OPENAI_ASSISTANT_ID environment variable
Environment variables:
OPENAI_API_KEY <value> - OpenAI api key (required)
OPENAI_ASSISTANT_ID <value> - OpenAI assistant id. Required for file operation commands
Examples:
Upload to code interpreter: gpt-files upload --destination=code ./main.ts
gpt-files upload -d code ./main.ts
New file name: gpt-files upload --file-name=report.txt ./report_2024-01.txt
gpt-files upload -n report.txt ./report_2024-01.txt
Overwrite existed: gpt-files upload --overwrite --file-name=report.txt ./report_2024-02.txt
gpt-files upload -o -n report.txt ./report_2024-02.txt