MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / _materialize_node

Function _materialize_node

masfactory/compatibility/chatdev/materialize.py:177–210  ·  view source on GitHub ↗
(
    owner: OwnerGraph,
    ext,
    options: ChatDevCompileOptions,
    id_to_graph_name: dict[str, str],
)

Source from the content-addressed store, hash-verified

175
176
177def _materialize_node(
178 owner: OwnerGraph,
179 ext,
180 options: ChatDevCompileOptions,
181 id_to_graph_name: dict[str, str],
182) -> Node:
183 gname = id_to_graph_name[ext.id]
184 attrs = {"chatdev_id": ext.id, "chatdev_label": ext.label, "chatdev_kind": ext.kind}
185 cfg = _node_config(ext)
186 kind = ext.kind
187
188 if kind == "agent":
189 forward = _make_agent_forward(ext.id, cfg, owner, options)
190 elif kind == "literal":
191 forward = _make_literal_forward(ext.id, cfg, owner)
192 elif kind == "loop_counter":
193 forward = _make_loop_counter_forward(ext.id, cfg, owner)
194 elif kind in {"SimplePhase", "ComposedPhase"}:
195 forward = _make_chain_phase_forward(ext.id, ext.raw or {}, owner)
196 elif kind == "majority_vote":
197 raw = ext.raw or {}
198 voters = raw.get("voter_ids") if isinstance(raw.get("voter_ids"), list) else []
199 forward = _make_majority_vote_forward(ext.id, [str(v) for v in voters], owner)
200 else:
201 forward = _make_passthrough_forward(ext.id, owner)
202
203 return owner.create_node(
204 CustomNode,
205 name=gname,
206 forward=forward,
207 pull_keys=None,
208 push_keys=None,
209 attributes=attrs,
210 )
211
212
213def _make_route_predicates(

Callers 2

_compile_loop_subgraphFunction · 0.70

Calls 8

_node_configFunction · 0.85
_make_agent_forwardFunction · 0.85
_make_literal_forwardFunction · 0.85
create_nodeMethod · 0.80

Tested by

no test coverage detected