ReqLLM.ParamTransform (ReqLLM v1.0.0)
View SourceComposable parameter transformation engine for applying model-specific rules to options.
Supports operations like drop, rename, set_default, enforce_constant, validate, and transform to handle model-specific parameter requirements in a declarative way.
Summary
Functions
Apply a sequence of transformation steps to a keyword list of options.
Types
@type key() :: atom()
@type step() :: {:drop, key(), message :: String.t() | nil} | {:rename, from :: key(), to :: key(), message :: String.t() | nil} | {:set_default, key(), value(), message :: String.t() | nil} | {:enforce_constant, key(), value(), on_mismatch :: :drop | :fix | :error, message :: String.t()} | {:validate, key(), (value() -> boolean()), message :: String.t()} | {:transform, key(), (value() -> value()), message :: String.t() | nil}
@type value() :: term()
Functions
Apply a sequence of transformation steps to a keyword list of options.
Returns {transformed_opts, warnings} where warnings is a list of messages
generated during transformations.
Examples
iex> opts = [temperature: 0.5, max_tokens: 100]
iex> steps = [
...> {:drop, :temperature, "Temperature not supported"},
...> {:rename, :max_tokens, :max_completion_tokens, "Renamed for reasoning model"}
...> ]
iex> {result, warnings} = ReqLLM.ParamTransform.apply(opts, steps)
iex> result
[max_completion_tokens: 100]
iex> warnings
["Renamed for reasoning model", "Temperature not supported"]