wren node: calibration setting, passed to wren's training as the installation's calibration records

This commit is contained in:
Melvin Strobl
2026-10-26 22:17:48 +01:00
parent ba75c78820
commit 7b453af3fe
3 changed files with 22 additions and 6 deletions
+8 -1
View File
@@ -269,6 +269,12 @@ class WrenNode(Node):
'as {"state": {"user_location": "kitchen"}, "command": "lights on", '
'"calls": [["kitchen_light", true]]}.',
)
calibration: list[dict[str, Any]] = Field(
default_factory=list,
description="Training only: commands in your own words, like "
"examples, that a new model's threshold is chosen on. It never "
"trains on them.",
)
tests: list[dict[str, Any]] = Field(
default_factory=list,
description="Training only: commands a new model is scored on, like "
@@ -355,10 +361,11 @@ class WrenNode(Node):
def installation(self) -> dict[str, Any]:
"""What wren's training flow learns from: the targets, each with a
value, and the ``examples`` and ``tests``."""
value, and the ``examples``, ``calibration`` and ``tests``."""
return {
"targets": [t | {"value": _unset(t)} for t in self.targets.values()],
"examples": self.cfg.examples,
"calibration": self.cfg.calibration,
"tests": self.cfg.tests,
}
+7 -1
View File
@@ -20,6 +20,7 @@ from tests.flow.conftest import FakeWren
FLOW = "wren_house"
PREFIX = f"{settings.API_V1_STR}/flows/{FLOW}/nodes"
EXAMPLES = [{"command": "warmer please", "calls": [["living_room_heating", 22]]}]
CALIBRATION = [{"command": "make it toasty", "calls": [["living_room_heating", 24]]}]
TESTS = [
{"command": "is it cold outside", "calls": [["outdoor_temperature"]]},
{"command": "good night", "calls": []},
@@ -49,6 +50,7 @@ def house(
"outdoor_temperature": {"description": "temperature outside"},
},
"examples": EXAMPLES,
"calibration": CALIBRATION,
"tests": TESTS,
},
"requires": [
@@ -121,7 +123,11 @@ def test_train_submits_the_node_as_wren_s_installation(
"value": 0.0,
},
]
assert (installation["examples"], installation["tests"]) == (EXAMPLES, TESTS)
assert (
installation["examples"],
installation["calibration"],
installation["tests"],
) == (EXAMPLES, CALIBRATION, TESTS)
def test_train_says_how_to_register_a_missing_training_flow(