mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-25 08:46:48 +02:00
fixbug: IndexableDocument.from_path error
This commit is contained in:
parent
ab77bde54c
commit
23fa792895
2 changed files with 7 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ from langchain.text_splitter import CharacterTextSplitter
|
|||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from tqdm import tqdm
|
||||
|
||||
from metagpt.logs import logger
|
||||
from metagpt.repo_parser import RepoParser
|
||||
|
||||
|
||||
|
|
@ -130,9 +131,12 @@ class IndexableDocument(Document):
|
|||
if isinstance(data, pd.DataFrame):
|
||||
validate_cols(content_col, data)
|
||||
return cls(data=data, content=str(data), content_col=content_col, meta_col=meta_col)
|
||||
else:
|
||||
try:
|
||||
content = data_path.read_text()
|
||||
return cls(data=data, content=content, content_col=content_col, meta_col=meta_col)
|
||||
except Exception as e:
|
||||
logger.debug(f"Load {str(data_path)} error: {e}")
|
||||
content = ""
|
||||
return cls(data=data, content=content, content_col=content_col, meta_col=meta_col)
|
||||
|
||||
def _get_docs_and_metadatas_by_df(self) -> (list, list):
|
||||
df = self.data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue