PERI-AI-dev / src /readers /text.py
LIANJie-Jason's picture
fix: Round 15 — 2 HIGH bugs fixed (sql_count citation audit + reader error handling)
a6b3188
Raw History Blame Contribute Delete
423 Bytes
"""Reader for plain text files: .txt, .md, .json, .do"""
def read_text(file_path: str) -> list[dict]:
try:
with open(file_path, "r", encoding="utf-8", errors="replace") as f:
text = f.read()
if not text.strip():
return []
return [{"page": 1, "text": text.strip()}]
except Exception as e:
print(f"Warning: Could not read {file_path}: {e}")
return []