run-llama / create-llama

The easiest way to get started with LlamaIndex
MIT License
799 stars 96 forks source link

mongodb not working with fast-api backend (0.1.35) #240

Closed aadnegture closed 2 weeks ago

aadnegture commented 4 weeks ago

I'm not getting the mongodb integration to work with fast-api. Poetry run generate runs without errors, but with this output:

2272
Parsing nodes: 0it [00:00, ?it/s]
Generating embeddings: 0it [00:00, ?it/s]
INFO:root:Finished generating the index

Where 2272 is from adding a print of store._collection.estimated_document_count() in the get_vector_store function. So the connection seems fine.

When calling the api it doesn't retrieve any nodes at all:

8:[{"type": "sources", "data": {"nodes": []}}] the logs of the api looks like this:

INFO:     127.0.0.1:64494 - "OPTIONS /api/chat HTTP/1.1" 200 OK
INFO:     Creating chat engine with filters: filters=[MetadataFilter(key='private', value='true', operator=<FilterOperator.NE: '!='>)] condition=<FilterCondition.AND: 'and'>    
INFO:     Connecting vector store...
2272
INFO:     Finished load index from vector store.
INFO:     127.0.0.1:64494 - "POST /api/chat HTTP/1.1" 200 OK
marcusschiesser commented 3 weeks ago

@aadnegture I guess that the metadata filters are not working with MongoDB. Can you please try:

filters = None  # generate_filters(doc_ids)

in chat.py and let me know if that works?

marcusschiesser commented 2 weeks ago

@aadnegture the problem is that you need to create the index in MongoDB, see https://github.com/run-llama/llama_index/blob/332d2b9e71acefa166355760c4bf391aa1f3fa48/llama-index-integrations/vector_stores/llama-index-vector-stores-mongodb/llama_index/vector_stores/mongodb/base.py#L54-L72

This is currently not done automatically