From f180ab5bdafe55d9eeda5364da93088effe160ae Mon Sep 17 00:00:00 2001 From: Ilya Kowalewski Date: Fri, 29 Nov 2024 21:34:14 +0200 Subject: [PATCH] feat: de-inlining Batch errors, int64 timestamps --- batch.go | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/batch.go b/batch.go index 90027917..6970afbf 100644 --- a/batch.go +++ b/batch.go @@ -73,36 +73,40 @@ func (r BatchEmbeddingRequest) MarshalBatchLineItem() []byte { } type Batch struct { - ID string `json:"id"` - Object string `json:"object"` - Endpoint BatchEndpoint `json:"endpoint"` - Errors *struct { - Object string `json:"object,omitempty"` - Data []struct { - Code string `json:"code,omitempty"` - Message string `json:"message,omitempty"` - Param *string `json:"param,omitempty"` - Line *int `json:"line,omitempty"` - } `json:"data"` - } `json:"errors"` + ID string `json:"id"` + Object string `json:"object"` InputFileID string `json:"input_file_id"` CompletionWindow string `json:"completion_window"` + Endpoint BatchEndpoint `json:"endpoint"` Status BatchStatus `json:"status"` - OutputFileID *string `json:"output_file_id"` - ErrorFileID *string `json:"error_file_id"` - CreatedAt int `json:"created_at"` - InProgressAt *int `json:"in_progress_at"` - ExpiresAt *int `json:"expires_at"` - FinalizingAt *int `json:"finalizing_at"` - CompletedAt *int `json:"completed_at"` - FailedAt *int `json:"failed_at"` - ExpiredAt *int `json:"expired_at"` - CancellingAt *int `json:"cancelling_at"` - CancelledAt *int `json:"cancelled_at"` - RequestCounts BatchRequestCounts `json:"request_counts"` + Errors *BatchErrors `json:"errors,omitempty"` + OutputFileID string `json:"output_file_id,omitempty"` + ErrorFileID string `json:"error_file_id,omitempty"` + CreatedAt int64 `json:"created_at"` + InProgressAt int64 `json:"in_progress_at,omitempty"` + ExpiresAt int64 `json:"expires_at,omitempty"` + FinalizingAt int64 `json:"finalizing_at,omitempty"` + CompletedAt int64 `json:"completed_at,omitempty"` + FailedAt int64 `json:"failed_at,omitempty"` + ExpiredAt int64 `json:"expired_at,omitempty"` + CancellingAt int64 `json:"cancelling_at,omitempty"` + CancelledAt int64 `json:"cancelled_at,omitempty"` + RequestCounts BatchRequestCounts `json:"request_counts,omitempty"` Metadata map[string]any `json:"metadata"` } +type BatchErrors struct { + Object string `json:"object,omitempty"` + Data []BatchError `json:"data"` +} + +type BatchError struct { + Code string `json:"code,omitempty"` + Message string `json:"message,omitempty"` + Param string `json:"param,omitempty"` + Line int `json:"line,omitempty"` +} + type BatchRequestCounts struct { Total int `json:"total"` Completed int `json:"completed"`