# Generated by SnakeBridge v0.13.0 - DO NOT EDIT MANUALLY # Regenerate with: mix compile # Library: dspy 3.1.2 # Python module: dspy.utils defmodule Dspy.Utils do @moduledoc """ Submodule bindings for `dspy.utils`. ## Version - Requested: 3.1.2 - Observed at generation: 3.1.2 ## Runtime Options All functions accept a `__runtime__` option for controlling execution behavior: Dspy.Utils.some_function(args, __runtime__: [timeout: 120_000]) ### Supported runtime options - `:timeout` - Call timeout in milliseconds (default: 120,000ms / 2 minutes) - `:timeout_profile` - Use a named profile (`:default`, `:ml_inference`, `:batch_job`, `:streaming`) - `:stream_timeout` - Timeout for streaming operations (default: 1,800,000ms / 30 minutes) - `:session_id` - Override the session ID for this call - `:pool_name` - Target a specific Snakepit pool (multi-pool setups) - `:affinity` - Override session affinity (`:hint`, `:strict_queue`, `:strict_fail_fast`) ### Timeout Profiles - `:default` - 2 minute timeout for regular calls - `:ml_inference` - 10 minute timeout for ML/LLM workloads - `:batch_job` - Unlimited timeout for long-running jobs - `:streaming` - 2 minute timeout, 30 minute stream_timeout ### Example with timeout override # For a long-running ML inference call Dspy.Utils.predict(data, __runtime__: [timeout_profile: :ml_inference]) # Or explicit timeout Dspy.Utils.predict(data, __runtime__: [timeout: 600_000]) # Route to a pool and enforce strict affinity Dspy.Utils.predict(data, __runtime__: [pool_name: :strict_pool, affinity: :strict_queue]) See `SnakeBridge.Defaults` for global timeout configuration. """ @doc false def __snakebridge_python_name__, do: "dspy.utils" @doc false def __snakebridge_library__, do: "dspy" @doc """ Python binding for `dspy.utils.download`. ## Parameters - `url` (term()) ## Returns - `term()` """ @spec download(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def download(url, opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, :download, [url], opts) end @doc """ Python binding for `dspy.utils.dummy_rm`. ## Parameters - `passages` (term() default: ()) ## Returns - `term()` """ @spec dummy_rm() :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec dummy_rm(keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec dummy_rm(term()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec dummy_rm(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def dummy_rm() do SnakeBridge.Runtime.call(__MODULE__, :dummy_rm, [], []) end def dummy_rm(opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :dummy_rm, [], opts) end def dummy_rm(passages) do SnakeBridge.Runtime.call(__MODULE__, :dummy_rm, [passages], []) end def dummy_rm(passages, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :dummy_rm, [passages], opts) end @doc """ Decorator / decorator creator for marking APIs experimental in the docstring. ## Parameters - `f` - The function to be decorated. - `version` - The version in which the API was introduced as experimental. The version is used to determine whether the API should be considered as stable or not when releasing a new version of DSPy. ## Returns - `term()` """ @spec experimental() :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec experimental(keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec experimental(term() | nil) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec experimental(term() | nil, keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec experimental(term() | nil, term()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec experimental(term() | nil, term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def experimental() do SnakeBridge.Runtime.call(__MODULE__, :experimental, [], []) end def experimental(opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :experimental, [], opts) end def experimental(f) do SnakeBridge.Runtime.call(__MODULE__, :experimental, [f], []) end def experimental(f, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :experimental, [f], opts) end def experimental(f, version) do SnakeBridge.Runtime.call(__MODULE__, :experimental, [f, version], []) end def experimental(f, version, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :experimental, [f, version], opts) end @doc """ Prints the last n prompts and their completions. ## Parameters - `history` (term()) - `n` (integer() default: 1) ## Returns - `term()` """ @spec pretty_print_history(term()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec pretty_print_history(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec pretty_print_history(term(), integer()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec pretty_print_history(term(), integer(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def pretty_print_history(history) do SnakeBridge.Runtime.call(__MODULE__, :pretty_print_history, [history], []) end def pretty_print_history(history, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :pretty_print_history, [history], opts) end def pretty_print_history(history, n) do SnakeBridge.Runtime.call(__MODULE__, :pretty_print_history, [history, n], []) end def pretty_print_history(history, n, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :pretty_print_history, [history, n], opts) end @doc """ Decorator to add callback functionality to instance methods. ## Parameters - `py_fn` (term()) ## Returns - `term()` """ @spec with_callbacks(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def with_callbacks(py_fn, opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, :with_callbacks, [py_fn], opts) end end