OpenAI #FtJobs: List

delete DEPRECATED

2023-08-22: “/v1/fine-tunes API” deprecated
2024-01-04: “/v1/fine-tunes API” obsolete
(Use “/v1/fine-tuning API” instead)

OpenAI #FtJobs: List

translate OpenAI #FtJobs: リスト

Lists all Fine-Tuning Jobs (FtJobs) in your organization. The number of all FtJobs and the TSV of all FtJobs can be obtained; start time, update time, status, Base MODEL, FtJob ID.

Auto Step icon
Configs for this Auto Step
AuthzConfU1
U1: Select HTTP_Authz Setting (Secret API Key as “Fixed Value”) *
SelectConfB1
B1: Select NUMBER of FtJobs (update)
SelectConfB3
B3: Select STRING that stores List TSV for FtJobs (update)
StrConfU2
U2: Set 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 numPocketFtJobs     = configs.getObject( "SelectConfB1" );      // NotRequired
const strPocketFtJobsTsv  = configs.getObject( "SelectConfB3" );      // NotRequired



////// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)



////// == Calculating / 演算 ==

//// OpenAI API > Documentation > API REFERENCE > Fine-tunes > List fine-tunes
//// https://platform.openai.com/docs/api-reference/fine-tunes/list

/// prepare request1
let request1Uri = "https://api.openai.com/v1/fine-tunes";
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.get( 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": "list",
  "data": [
    {
      "object": "fine-tune",
      "id": "ft-lN1WPLOp8rtoalbMG5Nctc0T",
      "hyperparams": {
        "n_epochs": 4,
        "batch_size": 1,
        "prompt_loss_weight": 0.01,
        "learning_rate_multiplier": 0.1
      },
      "organization_id": "org-xxxxxyyyyyzzzzzXXXXXYYYY",
      "model": "curie",
      "training_files": [
        {
          "object": "file",
          "id": "file-rM8tP15b9pZ2tJSLZEfUl7fG",
          "purpose": "fine-tune",
          "filename": "training-data-questetra-bpm-suite-assistant.jsonl",
          "bytes": 6823,
          "created_at": 1690249576,
          "status": "processed",
          "status_details": null
        }
      ],
      "validation_files": [],
      "result_files": [
        {
          "object": "file",
          "id": "file-tOsEJP0WH3BTcLxyBMz1aLX2",
          "purpose": "fine-tune-results",
          "filename": "compiled_results.csv",
          "bytes": 3549,
          "created_at": 1690367024,
          "status": "processed",
          "status_details": null
        }
      ],
      "created_at": 1690354635,
      "updated_at": 1690367024,
      "status": "succeeded",
      "fine_tuned_model": "curie:ft-questetra-2023-07-26-10-23-43"
    },
    {
      "object": "fine-tune",
      "id": "ft-pYZvA9NP5ddBbe6ud6Mexjne",
      "hyperparams": {
        "n_epochs": 4,
        "batch_size": 1,
        "prompt_loss_weight": 0.01,
        "learning_rate_multiplier": 0.1
      },
      "organization_id": "org-xxxxxyyyyyzzzzzXXXXXYYYY",
      "model": "curie",
      "training_files": [
        {
          "object": "file",
          "id": "file-Mn6hzvaWX3yfjjsHNMi2FiP1",
          "purpose": "fine-tune",
          "filename": "training-data-questetra-inc.jsonl",
          "bytes": 2711,
          "created_at": 1690358392,
          "status": "processed",
          "status_details": null
        }
      ],
      "validation_files": [],
      "result_files": [
        {
          "object": "file",
          "id": "file-526WjgJtypVc9A2gcR1BWh9m",
          "purpose": "fine-tune-results",
          "filename": "compiled_results.csv",
          "bytes": 1033,
          "created_at": 1690373766,
          "status": "processed",
          "status_details": null
        }
      ],
      "created_at": 1690358426,
      "updated_at": 1690373766,
      "status": "succeeded",
      "fine_tuned_model": "curie:ft-questetra-2023-07-26-12-16-05"
    }
  ]
}
*/

/// parse response1
const response1Obj = JSON.parse( response1Body );
let numFtJobs = response1Obj?.data?.length ?? 0;
let arrFtJobsData = [];
for ( let i = 0; i < numFtJobs; i++ ) { // FtJob ID, Base MODEL, start time, update time, status
  const dateTmpCreate = new Date ( response1Obj.data[i].created_at * 1000 );
  const dateTmpUpdate = new Date ( response1Obj.data[i].updated_at * 1000 );
  arrFtJobsData.push ( 
    dateTmpCreate.toISOString() + '\t' +
    dateTmpUpdate.toISOString() + '\t' +
    response1Obj.data[i].status + '\t' +
    response1Obj.data[i].model + '\t' +
    response1Obj.data[i].id
  );
}



////// == Data Updating / ワークフローデータへの代入 ==
if( numPocketFtJobs !== null ){
  engine.setData( numPocketFtJobs, new java.math.BigDecimal( numFtJobs ) );
}
if( strPocketFtJobsTsv !== null ){
  engine.setData( strPocketFtJobsTsv, arrFtJobsData.join('\n') );
}


} //////// END "main()" /////////////////////////////////////////////////////////////////



/*
Notes:
- This "Automated Step" will cancel the fine-tune job by FtJob ID.
    - Example of FtJob ID: "ft-AF1WoRqd3aJAHsqc9NY7iL8F"
- 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.
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:
- この[自動工程]は、FtJob IDでファインチューンJob(微調整ジョブ)をキャンセルします。
    - Example of FtJob ID: "ft-AF1WoRqd3aJAHsqc9NY7iL8F"
- この[自動工程]をワークフロー図に配置すれば、案件が到達する度にリクエストが自動送信されます。
    - OpenAI API サーバに対してリクエストが自動送出されます。(REST API通信)
    - OpenAI API サーバからのレスポンスが自動保存解析されます。
APPENDIX-ja
- この[アドオン自動工程]を含むワークフローアプリを運用するには[HTTP 認証設定]が必要です。
    - あらかじめ "Secret API Key" を取得しておいてください。
    - "Secret API Key" を通信トークンとしてセットします。[トークン直接指定]
*/

Download

warning Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.
(Installing Addon Auto-Steps are available only on the Professional edition.)

Notes

  • This Automated Step will cancel the fine-tune job by FtJob ID.
    • Example of FtJob ID: “ft-AF1WoRqd3aJAHsqc9NY7iL8F”
  • 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.

Capture

Lists all Fine-Tuning Jobs (FtJobs) of your organization. The number of all FtJobs and the TSV of all FtJobs can be obtained; start time, update time, status, Base MODEL, FtJob ID.

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”

See Also

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading