config.py patch

#6
by Naphula - opened

https://huggingface.co/spaces/Naphula/model_tools/blob/main/config.py

This custom config.py patch extends MergeKit's configuration system to support string and boolean parameter values in addition to the existing numeric and gradient list support.

Key Changes

Extended Type Definitions

The patch modifies the type aliases to include additional primitive types:

  • ScalarOrGradient now includes str and bool types alongside float and List[float]
  • ParameterSetting also includes str as a valid parameter type

Enhanced Parameter Evaluation

The evaluate_setting function is updated to handle these new types:

  • Direct return for str and bool values (line 29-30)
  • Support for lists containing mixed types including str and bool (line 39-40)
  • The function maintains backward compatibility with existing numeric and gradient interpolation logic

Impact

This patch allows MergeKit configurations to use:

  • String parameters for categorical settings
  • Boolean parameters for toggle/flag settings
  • Mixed-type lists for more complex parameter definitions

The change maintains full backward compatibility with existing numeric and gradient-based parameter systems while adding flexibility for non-numeric configuration options.

Notes

The rest of the configuration system remains unchanged - all the Pydantic models, validation logic, and the ConfigReader class work with these extended parameter types seamlessly. This is a targeted enhancement to the type system and parameter evaluation logic only.

Sign up or log in to comment