When you're accessing this database, what host/port do you use? For example, to load the data into it
Did you created the index one by one with hand
or with the llamaindex program ?
Hi @Vaylonn the index was created with llamaindex, i.e., I have used PDFReader to load the to storage on mongoDB. Now I plan only to access files stored under mongoDB for query without resorting loading them from memory. I am kind of trying to test question-retrieval directly from the files in the Mongo_Database.
Hi @chris, I am accessing from mongodb+srv://apcmiguel:**@cluster0.dkehzhx.mongodb.net/
it looks like you've included the port in the host string. Try removing that?
for the collection name, you'll need to specify one of the collections in the database. I'm not familiar with this UI but you could try docstore/data
From what I did, I created index under different names
mongodb_client = pymongo.MongoClient(mongo_uri)
db_name = f"{dossier}"
store = MongoDBAtlasVectorSearch(mongodb_client, db_name=db_name)
# Création ou mise à jour d'un index à partir de documents dans le dossier 'Sources'
# A commenter/décommenter si on veut créer ou mettre à jour un index
storage_context = StorageContext.from_defaults(vector_store=store)
docs = SimpleDirectoryReader("./Sources").load_data()
index = VectorStoreIndex.from_documents(docs, storage_context=storage_context)
and i can load different indexes like that
don't forget that without a search engine created in mongoDB you will not have the possibilty to query over the index
I didnt bother with ports
maybe you mean that you can't access any index at all
because you can't enter the mongo network
an Hi @Vaylonn, could you please indicate from the connection string (in the attached img) where to find the Host and the Port? I am still blind and unable to grasp it.
I tried your code but got lost on the MongoDBAtlasVectorSearch(mongodb_client, db_name=db_name), it was giving error.
So I am persisting on the code snippet as below:
if submit_button:
num_output = 512
llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo", max_tokens=num_output))
define LLM service context
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, chunk_size=1024)
MONGO_URI = os.environ["MONGO_URI"]
MONGODB_DATABASE = "AI"
SimpleMongoReader = download_loader('SimpleMongoReader')
host = "<host>"
port = "<port>"
db_name = "<db_name>"
collection_name = "<collection_name>"
query_dict is passed into db.collection.find()
query_dict = {}
reader = SimpleMongoReader(host, port)
documents = reader.load_data(db_name, collection_name, query_dict=query_dict)
nodes = service_context.node_parser.get_nodes_from_documents(documents)
storage_context = StorageContext.from_defaults(docstore=MongoDocumentStore.from_uri(uri=MONGO_URI, db_name=MONGODB_DATABASE),
index_store=MongoIndexStore.from_uri(uri=MONGO_URI, db_name=MONGODB_DATABASE),)
list_index = GPTListIndex(nodes, storage_context=storage_context)
vector_index = GPTVectorStoreIndex.from_documents(nodes, storage_context=storage_context)
keyword_table_index = GPTSimpleKeywordTableIndex(nodes, storage_context=storage_context)
vector_response = vector_index.as_query_engine().query(question)
st.success(vector_response)actually i didnt get trough this way since i'm using Azure open AI
mongo_uri = os.environ["MONGO_URI"] = "mongodb+srv://sxdinno:xxxx@indexatlasdb.vwrbmy3.mongodb.net/index?retryWrites=true&w=majority"
mongodb_client = pymongo.MongoClient(mongo_uri)
db_name = f"{dossier}"
store = MongoDBAtlasVectorSearch(mongodb_client, db_name=db_name)
# Création ou mise à jour d'un index à partir de documents dans le dossier 'Sources'
# A commenter/décommenter si on veut créer ou mettre à jour un index
# storage_context = StorageContext.from_defaults(vector_store=store)
# docs = SimpleDirectoryReader("./Sources").load_data()
# index = VectorStoreIndex.from_documents(docs, storage_context=storage_context)
# Initialisation de l'index via les index sur MongoDB Atlas
# Et inversement, commenter/décommenter si on veut juste query l'index existant
index = VectorStoreIndex.from_vector_store(store)