MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / _regex_capture_parts

Method _regex_capture_parts

examples/server/server.py:4655–4668  ·  view source on GitHub ↗
(
        cls,
        pattern: str,
    )

Source from the content-addressed store, hash-verified

4653
4654 @classmethod
4655 def _regex_capture_parts(
4656 cls,
4657 pattern: str,
4658 ) -> Optional[Tuple[str, str]]:
4659 normalized = pattern.lstrip("^")
4660 captures = [
4661 (index, token)
4662 for token in ("(.*?)", "(.*)")
4663 if (index := normalized.find(token)) >= 0
4664 ]
4665 if not captures:
4666 return None
4667 capture_index, capture_token = min(captures, key=lambda item: item[0])
4668 return normalized[:capture_index], normalized[capture_index + len(capture_token) :]
4669
4670 @classmethod
4671 def _regex_capture_end_literal_specs(cls, pattern: str) -> List[Tuple[str, bool]]:

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected