MCPcopy Create free account
hub / github.com/OpenBMB/ChatDev / _slice_context

Function _slice_context

functions/function_calling/file.py:1081–1100  ·  view source on GitHub ↗
(
    lines: Sequence[str],
    center_line: int,
    span: int,
    *,
    before: bool,
)

Source from the content-addressed store, hash-verified

1079
1080
1081def _slice_context(
1082 lines: Sequence[str],
1083 center_line: int,
1084 span: int,
1085 *,
1086 before: bool,
1087) -> List[str]:
1088 if span <= 0:
1089 return []
1090 if before:
1091 start_line = max(center_line - span, 1)
1092 end_line = center_line - 1
1093 else:
1094 start_line = center_line + 1
1095 end_line = min(center_line + span, len(lines))
1096 if end_line < start_line:
1097 return []
1098 start_idx = start_line - 1
1099 end_idx = end_line
1100 return list(lines[start_idx:end_idx])

Callers 1

search_in_filesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected