MCPcopy
hub / github.com/FoundationAgents/MetaGPT / from_path

Method from_path

metagpt/document.py:123–135  ·  view source on GitHub ↗
(cls, data_path: Path, content_col="content", meta_col="metadata")

Source from the content-addressed store, hash-verified

121
122 @classmethod
123 def from_path(cls, data_path: Path, content_col="content", meta_col="metadata"):
124 if not data_path.exists():
125 raise FileNotFoundError(f"File {data_path} not found.")
126 data = read_data(data_path)
127 if isinstance(data, pd.DataFrame):
128 validate_cols(content_col, data)
129 return cls(data=data, content=str(data), content_col=content_col, meta_col=meta_col)
130 try:
131 content = data_path.read_text()
132 except Exception as e:
133 logger.debug(f"Load {str(data_path)} error: {e}")
134 content = ""
135 return cls(data=data, content=content, content_col=content_col, meta_col=meta_col)
136
137 def _get_docs_and_metadatas_by_df(self) -> (list, list):
138 df = self.data

Callers

nothing calls this directly

Calls 3

read_dataFunction · 0.85
validate_colsFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected