wren leaves unnamed areas to the assistant; assistant targets take a closed set of values
wren drops a call on an area the command does not name (other than the
user's or, with none named, the living room): "switch on the appliances"
turned on the bathroom light at 0.97. The assistant's `values` setting gives
a str target its only values, explains them in the tool and confirms in the
word set for each ("Canopy open.").
This commit is contained in:
@@ -197,6 +197,19 @@ def _plain(command: str) -> str:
|
||||
return re.sub(r"[.,!?;:]+(?=\s|$)", "", command).strip().lower()
|
||||
|
||||
|
||||
def _asked(house: Any, command: str) -> set[str]:
|
||||
"""The areas a call may land on: those the command names, or else the
|
||||
user's and the living room.
|
||||
|
||||
That is how wren picks the areas it shows as the command's own. The few
|
||||
it adds besides are there to be told apart, and a call on one of them is a
|
||||
word the model never learned landing on a neighbour: "switch on the
|
||||
appliances" turned on the bathroom light at 0.97.
|
||||
"""
|
||||
named = {a for a in house.areas if re.search(rf"\b{re.escape(a)}\b", command)}
|
||||
return named or {house.user_area, "living room"}
|
||||
|
||||
|
||||
def _text(call: Any) -> str:
|
||||
"""The call as the chat shows it, less the device it names."""
|
||||
args = ", ".join(f"{k}={v}" for k, v in call.args.items() if k != "id")
|
||||
@@ -359,11 +372,13 @@ class WrenNode(Node):
|
||||
wren = _wren()
|
||||
specs = {spec.port: spec for spec in self.output_ports}
|
||||
house = self._house(wren, specs, presence, outdoor, dark)
|
||||
command = _plain(prompt)
|
||||
asked = _asked(house, command)
|
||||
# One BLAS thread answers in about half the time for a model this
|
||||
# small. Scoped to the call, so numpy elsewhere in the process keeps
|
||||
# its threads.
|
||||
with threadpool_limits(1):
|
||||
calls, confidence = wren.act(_plain(prompt), house)
|
||||
calls, confidence = wren.act(command, house)
|
||||
confidence = round(float(confidence), 3)
|
||||
write = self.cfg.apply and confidence >= self.cfg.min_confidence
|
||||
writes: dict[str, Any] = {}
|
||||
@@ -372,7 +387,7 @@ class WrenNode(Node):
|
||||
for call in calls:
|
||||
area, _, kind = str(call.args.get("id", "")).partition(":")
|
||||
ports = self.devices.get((area, kind), [])
|
||||
if call.tool.split(".")[0] != _TOOLS.get(kind):
|
||||
if call.tool.split(".")[0] != _TOOLS.get(kind) or area not in asked:
|
||||
ports = []
|
||||
hits = [
|
||||
(specs[port], value)
|
||||
|
||||
Reference in New Issue
Block a user