pip install llama-index★Thellama-indexstarter bundle pullsllama-index-core+ OpenAI LLM/embedding packages. For a lean install usepip install llama-index-coreand add integrations you need.pip install llama-index-llms-anthropic llama-index-embeddings-huggingfaceEverything is a separate namespace package:llama-index-llms-*,-embeddings-*,-vector-stores-*,-readers-*. Install only what you use.from llama_index.core import ( VectorStoreIndex, SimpleDirectoryReader, Settings, StorageContext)★Core abstractions live underllama_index.core. Provider classes live under their own module, e.g.from llama_index.llms.openai import OpenAI.export OPENAI_API_KEY="sk-..."Default LLM/embeddings are OpenAI unless you overrideSettings(card 3). Python 3.9+.
docs = SimpleDirectoryReader("data").load_data()★1— Load every file in a folder intoDocumentobjects (PDF, docx, md, txt, and more).index = VectorStoreIndex.from_documents(docs)★2— Chunk, embed, and store. Builds an in-memory vector index by default.qe = index.as_query_engine() resp = qe.query("What is X?")★3— Retrieve top chunks + synthesize an answer.str(resp)is the text;resp.source_nodesis the evidence.print(resp) # the grounded answer resp.source_nodes # retrieved chunks + scoresThat is retrieval-augmented generation end to end. Everything below is swapping or tuning one of these three steps.