MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / build_routing_features

Function build_routing_features

bench/evaluate.py:33–53  ·  view source on GitHub ↗
(payload: dict[str, object] | None)

Source from the content-addressed store, hash-verified

31
32
33def build_routing_features(payload: dict[str, object] | None) -> RoutingFeatures | None:
34 if not payload:
35 return None
36
37 data = dict(payload)
38 tool_names = data.get("tool_names", ())
39 if tool_names is None:
40 normalized_tool_names: tuple[str, ...] = ()
41 elif isinstance(tool_names, (list, tuple)):
42 normalized_tool_names = tuple(str(item) for item in tool_names)
43 else:
44 normalized_tool_names = (str(tool_names),)
45 data["tool_names"] = normalized_tool_names
46
47 for key in ("tier_floor", "tier_cap"):
48 value = data.get(key)
49 if value is None or isinstance(value, Tier):
50 continue
51 data[key] = Tier(str(value).strip().upper())
52
53 return RoutingFeatures(**data)
54
55
56def serialize_routing_features(features: RoutingFeatures | None) -> dict[str, object] | None:

Callers 1

evaluate_datasetFunction · 0.85

Calls 3

TierClass · 0.90
RoutingFeaturesClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected