Current section

Files

Jump to
dspex lib snakebridge_generated dspy copro.ex
Raw

lib/snakebridge_generated/dspy/copro.ex

# Generated by SnakeBridge v0.14.0 - DO NOT EDIT MANUALLY
# Regenerate with: mix compile
# Library: dspy 3.1.2
# Python module: dspy
# Python class: COPRO
defmodule Dspy.COPRO do
@moduledoc """
Wrapper for Python class COPRO.
"""
def __snakebridge_python_name__, do: "dspy"
def __snakebridge_python_class__, do: "COPRO"
def __snakebridge_library__, do: "dspy"
@opaque t :: SnakeBridge.Ref.t()
@doc """
Initialize self. See help(type(self)) for accurate signature.
## Parameters
- `prompt_model` (term() default: None)
- `metric` (term() default: None)
- `breadth` (term() default: 10)
- `depth` (term() default: 3)
- `init_temperature` (term() default: 1.4)
- `track_stats` (term() default: False)
- `kwargs` (term())
"""
@spec new(list(term()), keyword()) :: {:ok, SnakeBridge.Ref.t()} | {:error, Snakepit.Error.t()}
def new(args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_class(__MODULE__, :__init__, [] ++ List.wrap(args), opts)
end
@doc """
Python method `COPRO._check_candidates_equal`.
## Parameters
- `candidate1` (term())
- `candidate2` (term())
## Returns
- `term()`
"""
@spec _check_candidates_equal(SnakeBridge.Ref.t(), term(), term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def _check_candidates_equal(ref, candidate1, candidate2, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_check_candidates_equal, [candidate1, candidate2], opts)
end
@doc """
Python method `COPRO._drop_duplicates`.
## Parameters
- `candidates` (term())
## Returns
- `term()`
"""
@spec _drop_duplicates(SnakeBridge.Ref.t(), term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def _drop_duplicates(ref, candidates, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_drop_duplicates, [candidates], opts)
end
@doc """
Python method `COPRO._get_signature`.
## Parameters
- `predictor` (term())
## Returns
- `term()`
"""
@spec _get_signature(SnakeBridge.Ref.t(), term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def _get_signature(ref, predictor, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_get_signature, [predictor], opts)
end
@doc """
Python method `COPRO._print_signature`.
## Parameters
- `predictor` (term())
## Returns
- `term()`
"""
@spec _print_signature(SnakeBridge.Ref.t(), term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def _print_signature(ref, predictor, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_print_signature, [predictor], opts)
end
@doc """
Python method `COPRO._set_signature`.
## Parameters
- `predictor` (term())
- `updated_signature` (term())
## Returns
- `term()`
"""
@spec _set_signature(SnakeBridge.Ref.t(), term(), term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def _set_signature(ref, predictor, updated_signature, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :_set_signature, [predictor, updated_signature], opts)
end
@doc """
optimizes `signature` of `student` program - note that it may be zero-shot or already pre-optimized (demos already chosen - `demos != []`)
parameters:
student: program to optimize and left modified.
trainset: iterable of `Example`s
eval_kwargs: optional, dict
Additional keywords to go into `Evaluate` for the metric.
Returns optimized version of `student`.
## Parameters
- `student` (term())
- `trainset` (term() keyword-only, required)
- `eval_kwargs` (term() keyword-only, required)
## Returns
- `term()`
"""
@spec compile(SnakeBridge.Ref.t(), term(), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def compile(ref, student, opts \\ []) do
kw_keys = opts |> Keyword.keys() |> Enum.map(&to_string/1)
missing_kw = ["trainset", "eval_kwargs"] |> Enum.reject(&(&1 in kw_keys))
if missing_kw != [] do
raise ArgumentError,
"Missing required keyword-only arguments: " <> Enum.join(missing_kw, ", ")
end
SnakeBridge.Runtime.call_method(ref, :compile, [student], opts)
end
@doc """
Get the parameters of the teleprompter.
## Returns
- `%{optional(String.t()) => term()}`
"""
@spec get_params(SnakeBridge.Ref.t(), keyword()) ::
{:ok, %{optional(String.t()) => term()}} | {:error, Snakepit.Error.t()}
def get_params(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :get_params, [], opts)
end
end