Skip to content

Extra Models

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

minisweagent.models.extra.roulette

RouletteModelConfig dataclass

RouletteModelConfig(
    model_kwargs: list[dict], model_name: str = "roulette"
)

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: Callable = RouletteModelConfig,
    **kwargs,
)

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

Source code in src/minisweagent/models/extra/roulette.py
17
18
19
20
def __init__(self, *, config_class: Callable = 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]

config instance-attribute

config = config_class(**kwargs)

models instance-attribute

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

cost property

cost: float

n_calls property

n_calls: int

get_template_vars

get_template_vars() -> dict
Source code in src/minisweagent/models/extra/roulette.py
30
31
def get_template_vars(self) -> dict:
    return asdict(self.config) | {"n_model_calls": self.n_calls, "model_cost": self.cost}

select_model

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

query

query(*args, **kwargs) -> dict
Source code in src/minisweagent/models/extra/roulette.py
36
37
38
39
40
def query(self, *args, **kwargs) -> dict:
    model = self.select_model()
    response = model.query(*args, **kwargs)
    response["model_name"] = model.config.model_name
    return response

InterleavingModelConfig dataclass

InterleavingModelConfig(
    model_kwargs: list[dict],
    sequence: list[int] | None = None,
    model_name: str = "interleaving",
)

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: Callable = 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
53
54
55
def __init__(self, *, config_class: Callable = 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
57
58
59
60
61
62
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]