Gemini.Types.Response.EmbedContentBatchStats (GeminiEx v0.8.4)

View Source

Statistics about an async embedding batch job.

Tracks the progress and status of requests within a batch.

Fields

  • request_count: Total number of requests in the batch (required)
  • successful_request_count: Number of successfully completed requests
  • failed_request_count: Number of failed requests
  • pending_request_count: Number of requests still pending

Examples

# From API response
stats = EmbedContentBatchStats.from_api_response(%{
  "requestCount" => "100",
  "successfulRequestCount" => "75",
  "failedRequestCount" => "5",
  "pendingRequestCount" => "20"
})

# Check progress
EmbedContentBatchStats.progress_percentage(stats)
# => 80.0

# Check if complete
EmbedContentBatchStats.is_complete?(stats)
# => false

Summary

Functions

Calculates the failure rate of completed requests.

Creates stats from an API response map.

Checks if the batch is complete (no pending requests).

Calculates the progress percentage of the batch.

Calculates the success rate of completed requests.

Types

t()

@type t() :: %Gemini.Types.Response.EmbedContentBatchStats{
  failed_request_count: non_neg_integer() | nil,
  pending_request_count: non_neg_integer() | nil,
  request_count: non_neg_integer(),
  successful_request_count: non_neg_integer() | nil
}

Functions

failure_rate(stats)

@spec failure_rate(t()) :: float()

Calculates the failure rate of completed requests.

Parameters

  • stats: The batch statistics

Returns

Failure rate as a float percentage (0.0 to 100.0)

Examples

stats = %EmbedContentBatchStats{
  request_count: 100,
  successful_request_count: 80,
  failed_request_count: 20,
  pending_request_count: 0
}

EmbedContentBatchStats.failure_rate(stats)
# => 20.0

from_api_response(data)

@spec from_api_response(map()) :: t()

Creates stats from an API response map.

Handles both string and integer values from the API.

Parameters

  • data: Map containing batch statistics from the API

Returns

A new EmbedContentBatchStats struct

Examples

EmbedContentBatchStats.from_api_response(%{
  "requestCount" => "100",
  "successfulRequestCount" => "75"
})

is_complete?(embed_content_batch_stats)

@spec is_complete?(t()) :: boolean()

Checks if the batch is complete (no pending requests).

Parameters

  • stats: The batch statistics

Returns

true if no pending requests remain, false otherwise

Examples

stats = %EmbedContentBatchStats{
  request_count: 100,
  successful_request_count: 100,
  failed_request_count: 0,
  pending_request_count: 0
}

EmbedContentBatchStats.is_complete?(stats)
# => true

progress_percentage(stats)

@spec progress_percentage(t()) :: float()

Calculates the progress percentage of the batch.

Progress is calculated as: (successful + failed) / total * 100

Parameters

  • stats: The batch statistics

Returns

Progress as a float percentage (0.0 to 100.0)

Examples

stats = %EmbedContentBatchStats{
  request_count: 100,
  successful_request_count: 75,
  failed_request_count: 5,
  pending_request_count: 20
}

EmbedContentBatchStats.progress_percentage(stats)
# => 80.0

success_rate(stats)

@spec success_rate(t()) :: float()

Calculates the success rate of completed requests.

Parameters

  • stats: The batch statistics

Returns

Success rate as a float percentage (0.0 to 100.0)

Examples

stats = %EmbedContentBatchStats{
  request_count: 100,
  successful_request_count: 80,
  failed_request_count: 20,
  pending_request_count: 0
}

EmbedContentBatchStats.success_rate(stats)
# => 80.0