MCPcopy Create free account
hub / github.com/FastMAS/KVCOMM / extract_example

Method extract_example

KVCOMM/agents/final_decision.py:31–49  ·  view source on GitHub ↗

Return doctest-style assertions extracted from the task description.

(prompt: Dict[str, Any] | str)

Source from the content-addressed store, hash-verified

29
30 @staticmethod
31 def extract_example(prompt: Dict[str, Any] | str) -> List[str]:
32 """Return doctest-style assertions extracted from the task description."""
33 if isinstance(prompt, dict):
34 prompt_text = str(prompt.get("task", ""))
35 else:
36 prompt_text = str(prompt)
37
38 lines = [line.strip() for line in prompt_text.splitlines() if line.strip()]
39 results: List[str] = []
40 iterator = iter(lines)
41 for line in iterator:
42 if not line.startswith(">>>"):
43 continue
44 function_call = line[4:].strip()
45 expected_output = next(iterator, "").strip()
46 if not function_call or not expected_output:
47 continue
48 results.append(f"assert {function_call} == {expected_output}")
49 return results
50
51 @staticmethod
52 def _is_python_code_block(text: str) -> bool:

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected