Skip to content

Extra Models

These are advanced "meta-models" that combine or modify the behavior of other models.

minisweagent.models.extra.roulette

RouletteModelConfig

Bases: BaseModel

model_kwargs instance-attribute

model_kwargs: list[dict]

The models to choose from

model_name class-attribute instance-attribute

model_name: str = 'roulette'

RouletteModel

RouletteModel(
    *, config_class: type = RouletteModelConfig, **kwargs
)

This "meta"-model randomly selects one of the models at every call

Source code in src/minisweagent/models/extra/roulette.py
16
17
18
19
20
def __init__(self, *, config_class: type = RouletteModelConfig, **kwargs):
    """This "meta"-model randomly selects one of the models at every call"""
    self.config = config_class(**kwargs)
    self.models = [get_model(config=config) for config in self.config.model_kwargs]
    self._n_calls = 0

config instance-attribute

config = config_class(**kwargs)

models instance-attribute

models = [
    (get_model(config=config)) for config in (model_kwargs)
]

get_template_vars

get_template_vars(**kwargs) -> dict
Source code in src/minisweagent/models/extra/roulette.py
22
23
def get_template_vars(self, **kwargs) -> dict:
    return self.config.model_dump()

select_model

select_model() -> Model
Source code in src/minisweagent/models/extra/roulette.py
25
26
def select_model(self) -> Model:
    return random.choice(self.models)

query

query(*args, **kwargs) -> dict
Source code in src/minisweagent/models/extra/roulette.py
28
29
30
31
32
33
def query(self, *args, **kwargs) -> dict:
    model = self.select_model()
    self._n_calls += 1
    response = model.query(*args, **kwargs)
    response["model_name"] = model.config.model_name
    return response

serialize

serialize() -> dict
Source code in src/minisweagent/models/extra/roulette.py
35
36
37
38
39
40
41
42
43
def serialize(self) -> dict:
    return {
        "info": {
            "config": {
                "model": self.config.model_dump(mode="json"),
                "model_type": f"{self.__class__.__module__}.{self.__class__.__name__}",
            },
        }
    }

InterleavingModelConfig

Bases: BaseModel

model_kwargs instance-attribute

model_kwargs: list[dict]

sequence class-attribute instance-attribute

sequence: list[int] | None = None

If set to 0, 0, 1, we will return the first model 2 times, then the second model 1 time, then the first model again, etc.

model_name class-attribute instance-attribute

model_name: str = 'interleaving'

InterleavingModel

InterleavingModel(
    *,
    config_class: type = InterleavingModelConfig,
    **kwargs,
)

Bases: RouletteModel

This "meta"-model alternates between the models in the sequence for every call

Source code in src/minisweagent/models/extra/roulette.py
55
56
57
def __init__(self, *, config_class: type = InterleavingModelConfig, **kwargs):
    """This "meta"-model alternates between the models in the sequence for every call"""
    super().__init__(config_class=config_class, **kwargs)

select_model

select_model() -> Model
Source code in src/minisweagent/models/extra/roulette.py
59
60
61
62
63
64
def select_model(self) -> Model:
    if self.config.sequence is None:
        i_model = self._n_calls % len(self.models)
    else:
        i_model = self.config.sequence[self._n_calls % len(self.config.sequence)]
    return self.models[i_model]