Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update base.py #17269

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(
self.clean_json = clean_json

def load_data(
self, input_file: str, extra_info: Optional[Dict] = {}
self, input_file: str, metadata: Optional[Dict] = {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is technically a breaking change?

) -> List[Document]:
"""Load data from the input file."""
with open(input_file, encoding="utf-8") as f:
Expand All @@ -116,13 +116,13 @@ def load_data(
line for line in lines if not re.match(r"^[{}\[\],]*$", line)
]
documents.append(
Document(text="\n".join(useful_lines), metadata=extra_info)
Document(text="\n".join(useful_lines), metadata=metadata)
)

elif self.levels_back is None and self.clean_json is False:
# If levels_back isn't set and clean json is False, create documents without cleaning
json_output = json.dumps(data, ensure_ascii=self.ensure_ascii)
documents.append(Document(text=json_output, metadata=extra_info))
documents.append(Document(text=json_output, metadata=metadata))

elif self.levels_back is not None:
# If levels_back is set, we make the embeddings contain the labels
Expand All @@ -137,6 +137,6 @@ def load_data(
)
]
documents.append(
Document(text="\n".join(lines), metadata=extra_info)
Document(text="\n".join(lines), metadata=metadata)
)
return documents