# Provide URI to constructor, or use environment variable from markdown import Markdown import pymongo from llama_index.vector_stores.mongodb import MongoDBAtlasVectorSearch from llama_index.indices.vector_store.base import VectorStoreIndex from llama_index.storage.storage_context import StorageContext from llama_index.readers.file.base import SimpleDirectoryReader mongo_uri = "mongodb+srv://<username>:<password>@<host>/?retryWrites=true&w=majority" mongodb_client = pymongo.MongoClient(mongo_uri) store = MongoDBAtlasVectorSearch(mongodb_client) storage_context = StorageContext.from_defaults(vector_store=store) silva_docs = SimpleDirectoryReader(input_files=["data/Anderson_Silva.pdf"]).load_data() index = VectorStoreIndex.from_documents(silva_docs, storage_context=storage_context) response = index.as_query_engine().query("When was Anderson Silva born?") print(f"<b>{response}</b>")
python3 main.py <b>None</b>
pip show llama-index Name: llama-index Version: 0.8.21 Summary: Interface between LLMs and your data
_id 64f925142fcb48f3ce08145b id "f37888d5-4b17-4196-8eb4-f76e51ee0f3e" embedding Array 0 -0.02008351869881153 1 -0.00473610358312726 2 -0.007173654157668352 3 0.003149491734802723 4 0.006041328888386488 5 -0.00047971270396374166 6 -0.014116775244474411 7 -0.0012314886553213 8 -0.03010493889451027 9 -0.026755424216389656 10 0.001365401316434145 11 0.04260798171162605
silva_docs = SimpleDirectoryReader(input_files=["data/Anderson_Silva.pdf"]).load_data() print(silva_docs[:10])
python3 main.py [Document(id_='0298945e-39e3-4584-bc8d-70ad8b55b0c8', embedding=None, metadata={'page_label': '1', 'file_name': 'Anderson_Silva.pdf'}, excluded_embed_metadata_keys=[], excluded_llm_metadata_keys=[], relationships={}, hash='1093a3ddb5d2fe89710755177565d8f46177f1908ee7b2e5397fdea231a89c07', text='Anderson Silva\nSilva in 2012\nBorn Anderson da\nSilva[1]\n14 April 1975\nSΓ£o Paulo,\nBrazil[2]\nOther names The Spider\nResidence Los Angeles,\nCalifornia, United\nStates[3]\nNationality Brazilian\nAmerican[4]\nHeight 6 ft 2 in (1.88 m)\nWeight 185 lb (84 kg;\n13.2 st)\nDivision Middleweight\nLight\nHeavyweight\nReach 771β2[5] in\n(197 cm)\nFighting out ofCuritiba, Brazil\nTeam Chute Boxe\nAcademy (1997β\n2003)\nMuay Thai Dream\nTeam (2003β\n2006)[6]\nBrazilian Top\nTeam (2003β\n2006)\nBlack House\n(2007β2013)\nTeam Nogueira[7]\nKiller Bees Muay\nThai College\n(Founded/Current\nTeam)[8]Anderson Silva\nAnderson da Silva[1] (Portuguese pronunciation: [ΛΙΜdeΚ sΓ΅ Λ siwv Ι ]; born 14 April 1975) is a\nBrazilian mixed martial artist and boxe r. He is a former UFC Middleweight Champion and holds\nthe record for