MCPcopy Create free account
hub / github.com/GuDaStudio/GrokSearch / _split_function_call_sources

Function _split_function_call_sources

src/grok_search/sources.py:94–113  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

92
93
94def _split_function_call_sources(text: str) -> tuple[str, list[dict]] | None:
95 matches = list(_SOURCES_FUNCTION_PATTERN.finditer(text))
96 if not matches:
97 return None
98
99 for m in reversed(matches):
100 open_paren_idx = m.end() - 1
101 extracted = _extract_balanced_call_at_end(text, open_paren_idx)
102 if not extracted:
103 continue
104
105 close_paren_idx, args_text = extracted
106 sources = _parse_sources_payload(args_text)
107 if not sources:
108 continue
109
110 answer = text[: m.start()].rstrip()
111 return answer, sources
112
113 return None
114
115
116def _extract_balanced_call_at_end(text: str, open_paren_idx: int) -> tuple[int, str] | None:

Callers 1

split_answer_and_sourcesFunction · 0.85

Calls 2

_parse_sources_payloadFunction · 0.85

Tested by

no test coverage detected