MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / _extract_from_text

Function _extract_from_text

src/harness/submodules/specs.py:28–49  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

26
27def extract_submodule_result_value(value: Any) -> Optional[str]:
28 def _extract_from_text(text: str) -> Optional[str]:
29 if not text:
30 return None
31 lines = text.splitlines()
32 for idx, line in enumerate(lines):
33 stripped = line.strip()
34 if not stripped:
35 continue
36 if not stripped.startswith("RETURN:"):
37 return None
38 first_payload = stripped.split("RETURN:", 1)[1].strip()
39 rest_lines = []
40 for rest in lines[idx + 1 :]:
41 rest_stripped = rest.strip()
42 if rest_stripped.startswith("RETURN:"):
43 rest_lines.append(rest_stripped.split("RETURN:", 1)[1].strip())
44 else:
45 rest_lines.append(rest)
46 if rest_lines:
47 return "\n".join([first_payload] + rest_lines)
48 return first_payload
49 return None
50
51 if value is None:
52 return None

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected