MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _read_text_content

Function _read_text_content

functions/function_calling/file.py:794–804  ·  view source on GitHub ↗
(path: Path, encoding: str)

Source from the content-addressed store, hash-verified

792
793
794def _read_text_content(path: Path, encoding: str) -> tuple[str, str]:
795 if encoding != "auto":
796 return path.read_text(encoding=encoding), encoding
797
798 raw = path.read_bytes()
799 for candidate in _candidate_encodings():
800 try:
801 return raw.decode(candidate), candidate
802 except UnicodeDecodeError:
803 continue
804 return raw.decode("utf-8", errors="replace"), "utf-8"
805
806
807def _candidate_encodings() -> List[str]:

Callers 3

read_file_segmentFunction · 0.85
apply_text_editsFunction · 0.85

Calls 1

_candidate_encodingsFunction · 0.85

Tested by

no test coverage detected