Create a Document instance from a file path.
(cls, path: Path)
| 72 | |
| 73 | @classmethod |
| 74 | def from_path(cls, path: Path): |
| 75 | """ |
| 76 | Create a Document instance from a file path. |
| 77 | """ |
| 78 | if not path.exists(): |
| 79 | raise FileNotFoundError(f"File {path} not found.") |
| 80 | content = path.read_text() |
| 81 | return cls(content=content, path=path) |
| 82 | |
| 83 | @classmethod |
| 84 | def from_text(cls, text: str, path: Optional[Path] = None): |