@@ -1121,13 +1121,44 @@ class OpenAI(authToken: String, baseUri: Uri = OpenAIUris.OpenAIBaseUri) {
1121
1121
*
1122
1122
* @param createBatchRequest
1123
1123
* Request body that will be used to create a batch.
1124
+ * @return
1125
+ * The created Batch object.
1124
1126
*/
1125
1127
def createBatch (createBatchRequest : BatchRequestBody ): Request [Either [OpenAIException , BatchResponse ]] =
1126
1128
openAIAuthRequest
1127
1129
.post(openAIUris.Batches )
1128
1130
.body(createBatchRequest)
1129
1131
.response(asJson_parseErrors[BatchResponse ])
1130
1132
1133
+ /** Retrieves a batch.
1134
+ *
1135
+ * [[https://platform.openai.com/docs/api-reference/batch/retreive ]]
1136
+ *
1137
+ * @param batchId
1138
+ * The ID of the batch to retrieve.
1139
+ * @return
1140
+ * The Batch object matching the specified ID.
1141
+ */
1142
+ def retrieveBatch (batchId : String ): Request [Either [OpenAIException , BatchResponse ]] =
1143
+ openAIAuthRequest
1144
+ .get(openAIUris.batch(batchId))
1145
+ .response(asJson_parseErrors[BatchResponse ])
1146
+
1147
+ /** Cancels an in-progress batch. The batch will be in status cancelling for up to 10 minutes, before changing to cancelled, where it will
1148
+ * have partial results (if any) available in the output file.
1149
+ *
1150
+ * [[https://platform.openai.com/docs/api-reference/batch/cancel ]]
1151
+ *
1152
+ * @param batchId
1153
+ * The ID of the batch to cancel.
1154
+ * @return
1155
+ * The Batch object matching the specified ID.
1156
+ */
1157
+ def cancelBatch (batchId : String ): Request [Either [OpenAIException , BatchResponse ]] =
1158
+ openAIAuthRequest
1159
+ .post(openAIUris.cancelBatch(batchId))
1160
+ .response(asJson_parseErrors[BatchResponse ])
1161
+
1131
1162
protected val openAIAuthRequest : PartialRequest [Either [String , String ]] = basicRequest.auth
1132
1163
.bearer(authToken)
1133
1164
@@ -1163,6 +1194,9 @@ private class OpenAIUris(val baseUri: Uri) {
1163
1194
def fineTuningJobCheckpoints (fineTuningJobId : String ): Uri = fineTuningJob(fineTuningJobId).addPath(" checkpoints" )
1164
1195
def cancelFineTuningJob (fineTuningJobId : String ): Uri = fineTuningJob(fineTuningJobId).addPath(" cancel" )
1165
1196
1197
+ def batch (batchId : String ): Uri = Batches .addPath(batchId)
1198
+ def cancelBatch (batchId : String ): Uri = batch(batchId).addPath(" cancel" )
1199
+
1166
1200
def file (fileId : String ): Uri = Files .addPath(fileId)
1167
1201
def fileContent (fileId : String ): Uri = Files .addPath(fileId, " content" )
1168
1202
def model (modelId : String ): Uri = Models .addPath(modelId)
0 commit comments