# Generated by SnakeBridge v0.12.0 - DO NOT EDIT MANUALLY # Regenerate with: mix compile # Library: dspy 3.1.2 # Python module: dspy.utils.syncify defmodule Dspy.Utils.Syncify do @moduledoc """ Submodule bindings for `dspy.utils.syncify`. """ def __snakebridge_python_name__, do: "dspy.utils.syncify" def __snakebridge_library__, do: "dspy" @doc """ Run an async coroutine from a synchronous context. Parameters: - `coro` (term()) Returns: - `term()` """ @spec run_async(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def run_async(coro, opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, :run_async, [coro], opts) end @doc """ Convert an async DSPy module to a sync program. There are two modes of this function: - `in_place=True` (recommended): Modify the module in place. But this may not work if you already have a `forward` method which does different things from `aforward`. - `in_place=False`: Return a wrapper module. This changes the module's architecture, but it's more robust. ## Parameters - `program` - The async program to convert, must have an `aforward` method implemented. - `in_place` - If True, modify the module in place. Otherwise, return a wrapper module. Parameters: - `program` (term()) - `in_place` (boolean() default: True) Returns: - `term()` """ @spec syncify(term()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec syncify(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec syncify(term(), boolean()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec syncify(term(), boolean(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def syncify(program) do SnakeBridge.Runtime.call(__MODULE__, :syncify, [program], []) end def syncify(program, 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__, :syncify, [program], opts) end def syncify(program, in_place) do SnakeBridge.Runtime.call(__MODULE__, :syncify, [program, in_place], []) end def syncify(program, in_place, 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__, :syncify, [program, in_place], opts) end end