MongoDB Atlas is a developer data platform providing a suite of cloud database and data services that accelerate and simplify how you build with data.
MongoDB offers a forever free Atlas cluster in the public cloud which can be done upon creating an account here. You can also follow the quickstart here to get your free Atlas cluster!
We will be using the Patronus SDK in addition to LLamaIndex. LlamaIndex is a data framework that provides an interface for ingesting and indexing datasets, which integrates well with MongoDB’s Atlas data store.
from llama_index.node_parser import SimpleNodeParserfrom llama_index.storage.docstore import MongoDocumentStorenodes = SimpleNodeParser().get_nodes_from_documents(YOUR_DOCUMENTS)# You can get this from your test deployment in the MongoDB interfaceMONGODB_URI ="mongodb+srv://<username>:<password>@<cluster_identifier>.mongodb.net/?retryWrites=true&w=majority"docstore = MongoDocumentStore.from_uri(uri=MONGODB_URI)docstore.add_documents(nodes)
for INPUT in YOUR_INPUTS: vector_response = vector_index.as_query_engine().query(user_query) llm_output = vector_response.response source_text = [x.text for x in vector_response.source_nodes]