Skip to content

Commit fc22785

Browse files
committed
batch status methods
1 parent 3ffa6fb commit fc22785

File tree

1 file changed

+11
-1
lines changed
  • openai-core/src/main/scala/io/cequence/openaiscala/domain

1 file changed

+11
-1
lines changed

openai-core/src/main/scala/io/cequence/openaiscala/domain/Batch.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,17 @@ object Batch {
8686
cancelled_at: Option[Long],
8787
request_counts: Map[String, Int],
8888
metadata: Option[Map[String, String]]
89-
)
89+
) {
90+
def isRunning =
91+
List("in_progress", "validating", "finalizing", "cancelling").contains(status)
92+
93+
// "failed", "completed", "expired", "cancelled"
94+
def isFinished = !isRunning
95+
96+
def isSuccess = status == "completed"
97+
98+
def isFailedOrCancelledOrExpired = isFinished && !isSuccess
99+
}
90100

91101
case class BatchProcessingErrors(
92102
`object`: String,

0 commit comments

Comments
 (0)