OpenAI #File: 削除
OpenAI API サーバ上のファイルを削除します。ファイルIDを指定して削除します。ファイルIDは “file-xxxxxyyyyyzzzzzXXXXXYYYY” といった形式で、アップロードの際などに格納可能です。
Configs for this Auto Step
- AuthzConfU1
- U1: HTTP認証設定を選択してください(Secret API Key @トークン直接指定) *
- StrConfA1
- A1: ファイルのIDをセットしてください *#{EL}
- StrConfU2
- U2: OpenAI Organization ID をセットしてください(”org-xxxx”)#{EL}
Script (click to open)
// GraalJS standard mode Script Script (engine type: 3)
// cf. 'engine type: 2': "GraalJS Nashorn compatible mode" (renamed from "GraalJS" at 20230526)
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){
////// == Config Retrieving / 工程コンフィグの参照 ==
const strAuthzSetting = configs.get( "AuthzConfU1" ); /// REQUIRED
engine.log( " AutomatedTask Config: Authz Setting: " + strAuthzSetting );
const strOrgId = configs.get( "StrConfU2" ); // NotRequired
engine.log( " AutomatedTask Config: OpenAI-Organization: " + strOrgId );
const strId = configs.get( "StrConfA1" ); /// REQUIRED
if( strId === "" ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {A1: Id} must be non-empty string \n" );
}
////// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)
////// == Calculating / 演算 ==
//// OpenAI API > Documentation > API REFERENCE > FILES > Delete file
//// https://platform.openai.com/docs/api-reference/files/delete
/// prepare request1
let request1Uri = "https://api.openai.com/v1/files/" + strId;
let request1 = httpClient.begin(); // HttpRequestWrapper
request1 = request1.authSetting( strAuthzSetting ); // with "Authorization: Bearer XX"
if ( strOrgId !== "" ){
request1 = request1.header( "OpenAI-Organization", strOrgId );
}
/// try request1
const response1 = request1.delete( request1Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest1 Start: " + request1Uri );
const response1Code = response1.getStatusCode() + ""; // JavaNum to string
const response1Body = response1.getResponseAsString();
engine.log( " AutomatedTask ApiResponse1 Status: " + response1Code );
if( response1Code !== "200"){
throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
response1Code + "\n" + response1Body + "\n" );
}
/* engine.log( response1Body ); // debug
{
"object": "file",
"id": "file-jNyuVhzDqTRYS38pRJ7QTOG6",
"deleted": true
}
*/
/// parse response1
const response1Obj = JSON.parse( response1Body );
engine.log( " AutomatedTask OpenAI #deleted: " + response1Obj.id );
////// == Data Updating / ワークフローデータへの代入 ==
// (Nothing.)
} //////// END "main()" /////////////////////////////////////////////////////////////////
/*
Notes:
- If you place this "Automated Step" in the Workflow diagram, the request will be automatically sent every time the process token arrives.
- A request is automatically sent to the OpenAI API server. (REST API)
- The response from the OpenAI API server is automatically parsed.
- This "Automated Step" will delete the file on the OpenAI server.
- The size of all the files uploaded by one organization can be up to 1 GB. (as of 202307)
APPENDIX
- To activate a Workflow App that includes this Automated Step, "HTTP Authz Setting" is required
- Obtain a "Secret API Key" in advance.
- Set the key as the communication token in "Token Fixed Value"
Notes-ja:
- この[自動工程]をワークフロー図に配置すれば、案件が到達する度にリクエストが自動送信されます。
- OpenAI API サーバに対してリクエストが自動送出されます。(REST API通信)
- OpenAI API サーバからのレスポンスが自動保存解析されます。
- この[自動工程]は、OpenAI サーバ上のファイルを削除します。
- 1組織がアップロードできるファイルサイズの合計は1GBです。(202307現在)
APPENDIX-ja
- この[アドオン自動工程]を含むワークフローアプリを運用するには[HTTP 認証設定]が必要です。
- あらかじめ "Secret API Key" を取得しておいてください。
- "Secret API Key" を通信トークンとしてセットします。[トークン直接指定]
*/
Download
- openai-file-delete-2023.xml
- 2023-07-21 (C) Questetra, Inc. (MIT License)
(アドオン自動工程のインストールは Professional editionでのみ可能です)
Notes
- この[自動工程]をワークフロー図に配置すれば、案件が到達する度にリクエストが自動送信されます。
- OpenAI API サーバに対してリクエストが自動送出されます。(REST API通信)
- OpenAI API サーバからのレスポンスが自動保存解析されます。
- この[自動工程]は、OpenAI サーバ上のファイルを削除します。
- 1組織がアップロードできるファイルサイズの合計は1GBです。(202307現在)
Capture

Appendix
- この[アドオン自動工程]を含むワークフローアプリを運用するには[HTTP 認証設定]が必要です。
- あらかじめ “Secret API Key” を取得しておいてください。
- “Secret API Key” を通信トークンとしてセットします。[トークン直接指定]