-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
feat(mongo reader): field_extractors #18063
base: main
Are you sure you want to change the base?
Conversation
@@ -40,12 +41,6 @@ def __init__( | |||
|
|||
self.client = client | |||
|
|||
def _flatten(self, texts: List[Union[str, List[str]]]) -> List[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we remove flatten?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
texts
is already of type list[str]
, so calling _flatten(texts)
simply returns texts
itself without any modifications. Therefore, removing _flatten
simplifies the code without changing its behavior.
for item in cursor: | ||
try: | ||
texts = [str(item[name]) for name in field_names] | ||
texts = [ | ||
field_extractors.get(name, str)(item[name]) for name in field_names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.get(name, str)
does not work? What does this return when name
isn't in the dict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is dict.get
, so it will return the str
type (acting the same as the original) if name
isn't in the dict.
391928e
to
e02b503
Compare
Description
Add
field_extractors
to allow users to customize how data is extracted from MongoDB.New Package?
Did I fill in the
tool.llamahub
section in thepyproject.toml
and provide a detailed README.md for my new integration or package?Version Bump?
Did I bump the version in the
pyproject.toml
file of the package I am updating? (Except for thellama-index-core
package)Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.
Suggested Checklist:
make format; make lint
to appease the lint gods