glopenai/batch

Types

A batch processing job.

pub type Batch {
  Batch(
    id: String,
    object: String,
    endpoint: String,
    model: option.Option(String),
    errors: option.Option(BatchErrors),
    input_file_id: String,
    completion_window: String,
    status: BatchStatus,
    output_file_id: option.Option(String),
    error_file_id: option.Option(String),
    created_at: Int,
    in_progress_at: option.Option(Int),
    expires_at: option.Option(Int),
    finalizing_at: option.Option(Int),
    completed_at: option.Option(Int),
    failed_at: option.Option(Int),
    expired_at: option.Option(Int),
    cancelling_at: option.Option(Int),
    cancelled_at: option.Option(Int),
    request_counts: option.Option(BatchRequestCounts),
    usage: option.Option(shared.ResponseUsage),
    metadata: option.Option(dynamic.Dynamic),
  )
}

Constructors

The time frame within which the batch should be processed.

pub type BatchCompletionWindow {
  W24H
}

Constructors

  • W24H

The API endpoint to use for all requests in the batch.

pub type BatchEndpoint {
  V1Responses
  V1ChatCompletions
  V1Embeddings
  V1Completions
  V1Moderations
}

Constructors

  • V1Responses
  • V1ChatCompletions
  • V1Embeddings
  • V1Completions
  • V1Moderations

Error information for individual batch items.

pub type BatchError {
  BatchError(
    code: String,
    message: String,
    param: option.Option(String),
    line: option.Option(Int),
  )
}

Constructors

Container for batch errors.

pub type BatchErrors {
  BatchErrors(object: String, data: List(BatchError))
}

Constructors

  • BatchErrors(object: String, data: List(BatchError))

Configures when output files expire after creation.

pub type BatchFileExpirationAfter {
  BatchFileExpirationAfter(
    anchor: BatchFileExpirationAnchor,
    seconds: Int,
  )
}

Constructors

Anchor for file expiration timing.

pub type BatchFileExpirationAnchor {
  CreatedAt
}

Constructors

  • CreatedAt

Request to create a new batch.

pub type BatchRequest {
  BatchRequest(
    input_file_id: String,
    endpoint: BatchEndpoint,
    completion_window: BatchCompletionWindow,
    metadata: option.Option(dynamic.Dynamic),
    output_expires_after: option.Option(BatchFileExpirationAfter),
  )
}

Constructors

Counts of requests in different states within a batch.

pub type BatchRequestCounts {
  BatchRequestCounts(total: Int, completed: Int, failed: Int)
}

Constructors

  • BatchRequestCounts(total: Int, completed: Int, failed: Int)

A single request line in a batch input file (JSONL).

pub type BatchRequestInput {
  BatchRequestInput(
    custom_id: String,
    method: BatchRequestInputMethod,
    url: BatchEndpoint,
    body: option.Option(dynamic.Dynamic),
  )
}

Constructors

HTTP method for batch request inputs.

pub type BatchRequestInputMethod {
  Post
}

Constructors

  • Post

A single output line from a completed batch (JSONL).

pub type BatchRequestOutput {
  BatchRequestOutput(
    id: String,
    custom_id: String,
    response: option.Option(BatchRequestOutputResponse),
    error: option.Option(BatchRequestOutputError),
  )
}

Constructors

Error within a batch output line.

pub type BatchRequestOutputError {
  BatchRequestOutputError(code: String, message: String)
}

Constructors

  • BatchRequestOutputError(code: String, message: String)

Response body within a batch output line.

pub type BatchRequestOutputResponse {
  BatchRequestOutputResponse(
    status_code: Int,
    request_id: String,
    body: dynamic.Dynamic,
  )
}

Constructors

  • BatchRequestOutputResponse(
      status_code: Int,
      request_id: String,
      body: dynamic.Dynamic,
    )

Current processing status of a batch.

pub type BatchStatus {
  Validating
  Failed
  InProgress
  Finalizing
  Completed
  Expired
  Cancelling
  Cancelled
}

Constructors

  • Validating
  • Failed
  • InProgress
  • Finalizing
  • Completed
  • Expired
  • Cancelling
  • Cancelled

Response from listing batches.

pub type ListBatchesResponse {
  ListBatchesResponse(
    data: List(Batch),
    first_id: option.Option(String),
    last_id: option.Option(String),
    has_more: Bool,
    object: String,
  )
}

Constructors

Values

pub fn batch_completion_window_decoder() -> decode.Decoder(
  BatchCompletionWindow,
)
pub fn batch_completion_window_to_json(
  window: BatchCompletionWindow,
) -> json.Json
pub fn batch_decoder() -> decode.Decoder(Batch)
pub fn batch_endpoint_to_json(
  endpoint: BatchEndpoint,
) -> json.Json
pub fn batch_error_decoder() -> decode.Decoder(BatchError)
pub fn batch_errors_decoder() -> decode.Decoder(BatchErrors)
pub fn batch_file_expiration_after_to_json(
  expiration: BatchFileExpirationAfter,
) -> json.Json
pub fn batch_file_expiration_anchor_to_json(
  anchor: BatchFileExpirationAnchor,
) -> json.Json
pub fn batch_request_counts_decoder() -> decode.Decoder(
  BatchRequestCounts,
)
pub fn batch_request_input_decoder() -> decode.Decoder(
  BatchRequestInput,
)
pub fn batch_request_input_method_decoder() -> decode.Decoder(
  BatchRequestInputMethod,
)
pub fn batch_request_input_method_to_json(
  method: BatchRequestInputMethod,
) -> json.Json
pub fn batch_request_input_to_json(
  input: BatchRequestInput,
) -> json.Json
pub fn batch_request_output_decoder() -> decode.Decoder(
  BatchRequestOutput,
)
pub fn batch_request_output_error_decoder() -> decode.Decoder(
  BatchRequestOutputError,
)
pub fn batch_request_to_json(request: BatchRequest) -> json.Json
pub fn batch_status_decoder() -> decode.Decoder(BatchStatus)
pub fn batch_status_to_json(status: BatchStatus) -> json.Json
pub fn cancel_request(
  config: config.Config,
  batch_id: String,
) -> request.Request(String)

Build a request to cancel a batch.

pub fn cancel_response(
  response: response.Response(String),
) -> Result(Batch, error.GlopenaiError)

Parse the response from cancelling a batch.

pub fn create_request(
  config: config.Config,
  params: BatchRequest,
) -> request.Request(String)

Build a request to create a new batch.

pub fn create_response(
  response: response.Response(String),
) -> Result(Batch, error.GlopenaiError)

Parse the response from creating a batch.

pub fn list_request(
  config: config.Config,
) -> request.Request(String)

Build a request to list batches.

pub fn list_response(
  response: response.Response(String),
) -> Result(ListBatchesResponse, error.GlopenaiError)

Parse the response from listing batches.

pub fn new_batch_request(
  input_file_id input_file_id: String,
  endpoint endpoint: BatchEndpoint,
  completion_window completion_window: BatchCompletionWindow,
) -> BatchRequest

Create a new batch request with required fields.

pub fn retrieve_request(
  config: config.Config,
  batch_id: String,
) -> request.Request(String)

Build a request to retrieve a specific batch.

pub fn retrieve_response(
  response: response.Response(String),
) -> Result(Batch, error.GlopenaiError)

Parse the response from retrieving a batch.

pub fn with_metadata(
  request: BatchRequest,
  metadata: dynamic.Dynamic,
) -> BatchRequest
pub fn with_output_expires_after(
  request: BatchRequest,
  expiration: BatchFileExpirationAfter,
) -> BatchRequest
Search Document