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

Function _stringify_sample_io

applications/mapcoder/components/planning.py:208–226  ·  view source on GitHub ↗

Render the structured sample I/O list as a human-readable string for prompts. Tester (the CustomNode that actually runs them) consumes the list directly via `attrs['sample_io']`, but Agent prompts need a string snippet.

(sample_io: Any)

Source from the content-addressed store, hash-verified

206# ---------------------------------------------------------------------------
207
208def _stringify_sample_io(sample_io: Any) -> str:
209 """Render the structured sample I/O list as a human-readable string for prompts.
210
211 Tester (the CustomNode that actually runs them) consumes the list directly
212 via `attrs['sample_io']`, but Agent prompts need a string snippet.
213 """
214 if isinstance(sample_io, str):
215 return sample_io
216 if not isinstance(sample_io, list) or not sample_io:
217 return "(no sample I/O available)"
218 lines = []
219 for case in sample_io:
220 if not isinstance(case, dict):
221 continue
222 call = case.get("call", "")
223 expected = case.get("expected", "")
224 if call and expected:
225 lines.append(f"assert {call} == {expected}")
226 return "\n".join(lines) if lines else "(no sample I/O available)"

Callers 2

exemplar_picker_forwardFunction · 0.85
plan_picker_forwardFunction · 0.85

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected