94: raise ValueError(f"regions must be a list of at most {MAX_REGIONS}")
95: clean_regions: List[Dict[str, Any]] = []
96: for region in regions:
99: clean_regions.append({"id": _text(region.get("id"), "region id", 128),
103: history = request.get("history") or []
104: if not isinstance(history, list) or len(history) > MAX_HISTORY:
105: raise ValueError(f"history must be a list of at most {MAX_HISTORY}")
106: clean_history = []
107: for entry in history:
109: raise ValueError("a history item may contain only selected_id and outcome")
110: clean_history.append({k: _text(v, f"history {k}", 160) for k, v in entry.items()})
114: table: Dict[str, str] = {}
119: if not isinstance(identifier, str) or not _ID.fullmatch(identifier) or identifier in table:
121: table[identifier] = _text(candidate["description"], "candidate description", 600)
122: if not {"reobserve", "abstain"} <= set(table):
124: return {"goal": _text(request.get("goal"), "goal", 2000), "observation_id": str(request.get("observation_id", ""))[:256],
125: "regions": clean_regions, "history": clean_history, "table": table}
132: table = valid["table"]
136: "observation_id": valid["observation_id"], "probabilities": probabilities or {}}
140: state = {"goal": valid["goal"], "on_screen": valid["regions"], "already_tried": valid["history"]}
141: question = client.choice("Which single action should be taken next to move toward the goal?", table)
147: if picked["confidence"] < MIN_CONFIDENCE:
root@213-238-170-219:/home/hermes#