Current section

Files

Jump to
dspex lib snakebridge_generated dspy rlm.ex
Raw

lib/snakebridge_generated/dspy/rlm.ex

# Generated by SnakeBridge v0.12.0 - DO NOT EDIT MANUALLY
# Regenerate with: mix compile
# Library: dspy 3.1.2
# Python module: dspy
# Python class: RLM
defmodule Dspy.RLM do
def __snakebridge_python_name__, do: "dspy"
def __snakebridge_python_class__, do: "RLM"
def __snakebridge_library__, do: "dspy"
@opaque t :: SnakeBridge.Ref.t()
@spec new(term(), term(), term(), term(), term(), term(), term(), term(), keyword()) ::
{:ok, SnakeBridge.Ref.t()} | {:error, Snakepit.Error.t()}
def new(
signature,
max_iterations,
max_llm_calls,
max_output_chars,
verbose,
tools,
sub_lm,
interpreter,
opts \\ []
) do
SnakeBridge.Runtime.call_class(
__MODULE__,
:__init__,
[
signature,
max_iterations,
max_llm_calls,
max_output_chars,
verbose,
tools,
sub_lm,
interpreter
],
opts
)
end
@spec load(SnakeBridge.Ref.t(), term(), list(term()), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def load(ref, path, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :load, [path] ++ List.wrap(args), opts)
end
@spec deepcopy(SnakeBridge.Ref.t(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def deepcopy(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :deepcopy, [], opts)
end
@spec _set_lm_usage(SnakeBridge.Ref.t(), %{optional(String.t()) => term()}, term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def _set_lm_usage(ref, tokens, output, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_set_lm_usage, [tokens, output], opts)
end
@spec _build_variables(SnakeBridge.Ref.t(), keyword()) ::
{:ok, list(Dspy.Primitives.ReplTypes.REPLVariable.t())} | {:error, Snakepit.Error.t()}
def _build_variables(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_build_variables, [], opts)
end
@spec save(SnakeBridge.Ref.t(), term(), list(term()), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def save(ref, path, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :save, [path] ++ List.wrap(args), opts)
end
@spec batch(SnakeBridge.Ref.t(), list(Dspy.Primitives.Example.t()), list(term()), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def batch(ref, examples, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :batch, [examples] ++ List.wrap(args), opts)
end
@spec aforward(SnakeBridge.Ref.t(), keyword()) ::
{:ok, Dspy.Primitives.Prediction.t()} | {:error, Snakepit.Error.t()}
def aforward(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :aforward, [], opts)
end
@spec _get_output_fields_info(SnakeBridge.Ref.t(), keyword()) ::
{:ok, list(%{optional(term()) => term()})} | {:error, Snakepit.Error.t()}
def _get_output_fields_info(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_get_output_fields_info, [], opts)
end
@spec _validate_tools(SnakeBridge.Ref.t(), %{optional(String.t()) => term()}, keyword()) ::
{:ok, nil} | {:error, Snakepit.Error.t()}
def _validate_tools(ref, tools, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_validate_tools, [tools], opts)
end
@spec get_lm(SnakeBridge.Ref.t(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def get_lm(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :get_lm, [], opts)
end
@spec _process_execution_result(
SnakeBridge.Ref.t(),
term(),
term(),
Dspy.Primitives.ReplTypes.REPLHistory.t(),
list(String.t()),
keyword()
) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def _process_execution_result(ref, pred, result, history, output_field_names, opts \\ []) do
SnakeBridge.Runtime.call_method(
ref,
:_process_execution_result,
[pred, result, history, output_field_names],
opts
)
end
@spec dump_state(SnakeBridge.Ref.t(), list(term()), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def dump_state(ref, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :dump_state, [] ++ List.wrap(args), opts)
end
@spec _prepare_execution_tools(SnakeBridge.Ref.t(), keyword()) ::
{:ok, %{optional(String.t()) => term()}} | {:error, Snakepit.Error.t()}
def _prepare_execution_tools(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_prepare_execution_tools, [], opts)
end
@spec _format_tool_docs(SnakeBridge.Ref.t(), %{optional(String.t()) => term()}, keyword()) ::
{:ok, String.t()} | {:error, Snakepit.Error.t()}
def _format_tool_docs(ref, tools, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_format_tool_docs, [tools], opts)
end
@spec load_state(SnakeBridge.Ref.t(), term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def load_state(ref, state, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :load_state, [state], opts)
end
@spec predictors(SnakeBridge.Ref.t(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def predictors(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :predictors, [], opts)
end
@spec _validate_inputs(SnakeBridge.Ref.t(), %{optional(String.t()) => term()}, keyword()) ::
{:ok, nil} | {:error, Snakepit.Error.t()}
def _validate_inputs(ref, input_args, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_validate_inputs, [input_args], opts)
end
@spec _aexecute_iteration(
SnakeBridge.Ref.t(),
Dspy.Primitives.CodeInterpreter.t(),
list(Dspy.Primitives.ReplTypes.REPLVariable.t()),
Dspy.Primitives.ReplTypes.REPLHistory.t(),
integer(),
%{optional(String.t()) => term()},
list(String.t()),
keyword()
) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def _aexecute_iteration(
ref,
repl,
variables,
history,
iteration,
input_args,
output_field_names,
opts \\ []
) do
SnakeBridge.Runtime.call_method(
ref,
:_aexecute_iteration,
[repl, variables, history, iteration, input_args, output_field_names],
opts
)
end
@spec _inject_execution_context(
SnakeBridge.Ref.t(),
Dspy.Primitives.CodeInterpreter.t(),
%{optional(String.t()) => term()},
keyword()
) :: {:ok, nil} | {:error, Snakepit.Error.t()}
def _inject_execution_context(ref, interpreter, execution_tools, opts \\ []) do
SnakeBridge.Runtime.call_method(
ref,
:_inject_execution_context,
[interpreter, execution_tools],
opts
)
end
@spec _make_llm_tools(SnakeBridge.Ref.t(), list(term()), keyword()) ::
{:ok, %{optional(String.t()) => term()}} | {:error, Snakepit.Error.t()}
def _make_llm_tools(ref, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :_make_llm_tools, [] ++ List.wrap(args), opts)
end
@spec _interpreter_context(SnakeBridge.Ref.t(), %{optional(String.t()) => term()}, keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def _interpreter_context(ref, execution_tools, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_interpreter_context, [execution_tools], opts)
end
@spec set_lm(SnakeBridge.Ref.t(), term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def set_lm(ref, lm, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :set_lm, [lm], opts)
end
@spec inspect_history(SnakeBridge.Ref.t(), list(term()), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def inspect_history(ref, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :inspect_history, [] ++ List.wrap(args), opts)
end
@spec _format_output(SnakeBridge.Ref.t(), String.t(), keyword()) ::
{:ok, String.t()} | {:error, Snakepit.Error.t()}
def _format_output(ref, output, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_format_output, [output], opts)
end
@spec named_parameters(SnakeBridge.Ref.t(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def named_parameters(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :named_parameters, [], opts)
end
@spec reset_copy(SnakeBridge.Ref.t(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def reset_copy(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :reset_copy, [], opts)
end
@spec _base_init(SnakeBridge.Ref.t(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def _base_init(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_base_init, [], opts)
end
@spec named_sub_modules(SnakeBridge.Ref.t(), list(term()), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def named_sub_modules(ref, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :named_sub_modules, [] ++ List.wrap(args), opts)
end
@spec _extract_fallback(
SnakeBridge.Ref.t(),
list(Dspy.Primitives.ReplTypes.REPLVariable.t()),
Dspy.Primitives.ReplTypes.REPLHistory.t(),
list(String.t()),
keyword()
) :: {:ok, Dspy.Primitives.Prediction.t()} | {:error, Snakepit.Error.t()}
def _extract_fallback(ref, variables, history, output_field_names, opts \\ []) do
SnakeBridge.Runtime.call_method(
ref,
:_extract_fallback,
[variables, history, output_field_names],
opts
)
end
@spec _build_signatures(SnakeBridge.Ref.t(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def _build_signatures(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_build_signatures, [], opts)
end
@spec _execute_iteration(
SnakeBridge.Ref.t(),
Dspy.Primitives.CodeInterpreter.t(),
list(Dspy.Primitives.ReplTypes.REPLVariable.t()),
Dspy.Primitives.ReplTypes.REPLHistory.t(),
integer(),
%{optional(String.t()) => term()},
list(String.t()),
keyword()
) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def _execute_iteration(
ref,
repl,
variables,
history,
iteration,
input_args,
output_field_names,
opts \\ []
) do
SnakeBridge.Runtime.call_method(
ref,
:_execute_iteration,
[repl, variables, history, iteration, input_args, output_field_names],
opts
)
end
@spec forward(SnakeBridge.Ref.t(), keyword()) ::
{:ok, Dspy.Primitives.Prediction.t()} | {:error, Snakepit.Error.t()}
def forward(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :forward, [], opts)
end
@spec _aextract_fallback(
SnakeBridge.Ref.t(),
list(Dspy.Primitives.ReplTypes.REPLVariable.t()),
Dspy.Primitives.ReplTypes.REPLHistory.t(),
list(String.t()),
keyword()
) :: {:ok, Dspy.Primitives.Prediction.t()} | {:error, Snakepit.Error.t()}
def _aextract_fallback(ref, variables, history, output_field_names, opts \\ []) do
SnakeBridge.Runtime.call_method(
ref,
:_aextract_fallback,
[variables, history, output_field_names],
opts
)
end
@spec acall(SnakeBridge.Ref.t(), list(term()), keyword()) ::
{:ok, Dspy.Primitives.Prediction.t()} | {:error, Snakepit.Error.t()}
def acall(ref, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :acall, [] ++ List.wrap(args), opts)
end
@spec named_predictors(SnakeBridge.Ref.t(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def named_predictors(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :named_predictors, [], opts)
end
@spec _process_final_output(
SnakeBridge.Ref.t(),
Dspy.Primitives.CodeInterpreter.FinalOutput.t(),
list(String.t()),
keyword()
) :: {:ok, {term(), term()}} | {:error, Snakepit.Error.t()}
def _process_final_output(ref, result, output_field_names, opts \\ []) do
SnakeBridge.Runtime.call_method(
ref,
:_process_final_output,
[result, output_field_names],
opts
)
end
@spec parameters(SnakeBridge.Ref.t(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def parameters(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :parameters, [], opts)
end
@spec map_named_predictors(SnakeBridge.Ref.t(), term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def map_named_predictors(ref, func, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :map_named_predictors, [func], opts)
end
@spec _reserved_tool_names(SnakeBridge.Ref.t()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def _reserved_tool_names(ref) do
SnakeBridge.Runtime.get_attr(ref, :_RESERVED_TOOL_NAMES)
end
@spec tools(SnakeBridge.Ref.t()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
def tools(ref) do
SnakeBridge.Runtime.get_attr(ref, :tools)
end
end