Initialize with a list of outputs to return in sequence.
Source code in src/minisweagent/models/test_models.py
| def __init__(self, **kwargs):
"""
Initialize with a list of outputs to return in sequence.
"""
self.config = DeterministicModelConfig(**kwargs)
self.current_index = -1
self.cost = 0.0
self.n_calls = 0
|
config
instance-attribute
current_index
instance-attribute
n_calls
instance-attribute
query
query(messages: list[dict[str, str]], **kwargs) -> dict
Source code in src/minisweagent/models/test_models.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38 | def query(self, messages: list[dict[str, str]], **kwargs) -> dict:
self.current_index += 1
output = self.config.outputs[self.current_index]
if "/sleep" in output:
print("SLEEPING")
time.sleep(float(output.split("/sleep")[1]))
return self.query(messages, **kwargs)
if "/warning" in output:
logging.warning(output.split("/warning")[1])
return self.query(messages, **kwargs)
self.n_calls += 1
self.cost += self.config.cost_per_call
GLOBAL_MODEL_STATS.add(self.config.cost_per_call)
return {"content": output}
|