Find answers from the community

Updated 5 months ago

Mongo Reader

At a glance
Anyone had any luck with the SimpleMongoReader?
I get this error when attempting to following the example from https://github.com/jerryjliu/llama_index/blob/main/examples/data_connectors/MongoDemo.ipynb

documents = reader.load_data(db_name, collection_name, field_names, query_dict) TypeError: SimpleMongoReader.load_data() takes from 3 to 4 positional arguments but 5 were given
I have the latest from Pypi (llama-index 0.5.23.post1)

The only difference from the example in the notebook, to my code is that I am passing a URI to the constructor, rather than host and port
L
S
14 comments
Hmmm, looking at the source code, I feel like you did it right?

https://github.com/jerryjliu/llama_index/blob/main/gpt_index/readers/mongo.py#L46

I see the file was updated 3 days ago though πŸ‘€
Yes, I always doubt my Python-foo in the first instance. Worthy of me raising a git issue?
I think so! Seems very sus
Did you try calling with the query dict as a kwarg instead? Like the notebook?

I feel like that shouldn't matter but worth trying
documents = reader.load_data(db_name, collection_name, field_names, query_dict=query_dict)
Yeah, I had tried that earlier, but that I get the
SimpleMongoReader.load_data() got multiple values for argument 'query_dict'
So I tried naming field_names but get
SimpleMongoReader.load_data() got an unexpected keyword argument 'field_names'
And at that point I think I have the wrong library version, but I've checked the installed files and they have the recent updates.
πŸ˜΅β€πŸ’«
wait, so you tried documents = reader.load_data(db_name, collection_name, field_names=field_names, query_dict=query_dict)
if so, sounds like some wacky ass bug lol
More likely me being a numpty . ..
I just searched the venv folder and found the ./readers/llamahub_modules/mongo/base.py file and then a ./readers/mongo.py file, both with different definitions of the load_data function.
I'm not sure the difference yet. These are installed using pip, so would assume it's correct.
Appreciate you taking the tipe to respond to earlier queries - you are one busy person! Cheers
haha no worries! I hope that fixes some stuff by switching! πŸ™
haha, found the issue, was me being a numpty I guess.
I was using the llama_index.download_loader('SimpleMongoReader')
instead of a
from llama_index import SimpleMongoReader
Not sure why the difference, but now done.
noooo haha good catch!!!

Yea, there's a separate repo of loaders on llama hub, but the most common ones we have implemented locally too (and obviously they aren't at feature parity, oof)
Add a reply
Sign up and join the conversation on Discord