Classes
CLASS ModelOption
A type that wraps around model options.
Uses sentinel values (wrapped by @@@) to provide backend and model-agnostic keys for common model options.
Create a dictionary containing model options like this:
TOOLS: Sentinel key for a list or dict of tools to expose for tool calling.MAX_NEW_TOKENS: Sentinel key for the maximum number of new tokens to generate.SYSTEM_PROMPT: Sentinel key for the system prompt string.TEMPERATURE: Key for the sampling temperature (passed through to the backend).CONTEXT_WINDOW: Sentinel key for the context window size.THINKING: Sentinel key for enabling/configuring reasoning/thinking mode.SEED: Sentinel key for the random seed for reproducible generation.STREAM: Sentinel key for enabling streaming responses.
FUNC replace_keys
options renamed according to from_to.
Returns a new dict with the keys in options replaced with the corresponding value for that key in from_to.
- Any key with value == None is treated the same as the key missing.
-
If the destination key already exists in
options, the original value is kept in the output. -
Regardless of the presence of the destination key in
options, the source key is always absent in the output.
- Notice that “M1” keeps the original value “m1”, rather than “v1”.
- Notice that both “k1” and “k2” are absent in the output.
options: The source dictionary whose keys may be renamed.from_to: Mapping of old key names to new key names.
- dict[str, Any]: A new dictionary with the specified keys renamed.
FUNC remove_special_keys
model_options with all sentinel-valued keys removed.
Sentinel keys are those whose names start with @@@ (e.g. ModelOption.TOOLS).
These are Mellea-internal keys that must not be forwarded to backend APIs.
Args:
model_options: A model options dictionary that may contain sentinel keys.
- dict[str, Any]: A new dictionary with all
@@@-prefixed keys omitted.
FUNC merge_model_options
overwrite_opts taking precedence on conflicts.
Creates a new dict that contains all keys and values from persistent opts and overwrite opts.
If there are duplicate keys, overwrite opts key value pairs will be used.
Args:
persistent_opts: Base model options (lower precedence).overwrite_opts: Per-call model options that overridepersistent_optson key conflicts;Noneis treated as empty.
- dict[str, Any]: A new merged dictionary.