Current section
Files
Jump to
Current section
Files
lib/snakebridge_generated/dspy/utils/unbatchify/unbatchify.ex
# Generated by SnakeBridge v0.13.0 - DO NOT EDIT MANUALLY
# Regenerate with: mix compile
# Library: dspy 3.1.2
# Python module: dspy.utils.unbatchify
# Python class: Unbatchify
defmodule Dspy.Utils.Unbatchify do
@moduledoc """
Wrapper for Python class Unbatchify.
"""
def __snakebridge_python_name__, do: "dspy.utils.unbatchify"
def __snakebridge_python_class__, do: "Unbatchify"
def __snakebridge_library__, do: "dspy"
@opaque t :: SnakeBridge.Ref.t()
@doc """
Initializes the Unbatchify.
## Parameters
- `batch_fn` - The batch-processing function that accepts a list of inputs and returns a list of outputs.
- `max_batch_size` - The maximum number of items to include in a batch.
- `max_wait_time` - The maximum time (in seconds) to wait for batch to fill before processing.
"""
@spec new(term(), list(term()), keyword()) ::
{:ok, SnakeBridge.Ref.t()} | {:error, Snakepit.Error.t()}
def new(batch_fn, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_class(__MODULE__, :__init__, [batch_fn] ++ List.wrap(args), opts)
end
@doc """
Worker thread that batches inputs and processes them using batch_fn.
## Returns
- `term()`
"""
@spec _worker(SnakeBridge.Ref.t(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def _worker(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_worker, [], opts)
end
@doc """
Stops the worker thread and cleans up resources.
## Returns
- `term()`
"""
@spec close(SnakeBridge.Ref.t(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def close(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :close, [], opts)
end
end