Knowing the pipeline and the package layout prevents import errors and confusion from outdated tutorials.
Imagine asking a question about your company's 500-page handbook and getting an answer with the exact paragraphs it came from. That is what LlamaIndex is built for: connecting LLMs to your data.
Its core job is retrieval-augmented generation (RAG), done in stages:
- Load: read files, web pages or databases into
Documentobjects. - Index: split documents into small chunks called nodes, turn them into embeddings and store them.
- Query: find the chunks most relevant to a question and give them to the LLM to write an answer.
On top of that, LlamaIndex has agents (LLMs that use tools, including your indexes, in a loop) and Workflows, a way to write multi-step AI programs as steps that react to events.
Packages. LlamaIndex is split into many pip packages:
llama-index-core: all the core classes. Imports start withllama_index.core.- Integrations, one package each:
llama-index-llms-openai,llama-index-llms-anthropic,llama-index-llms-ollama,llama-index-embeddings-huggingface,llama-index-vector-stores-chromaand hundreds more. Their imports look likellama_index.llms.openai. llama-index: a starter bundle with core plus the OpenAI integrations.
Older tutorials (before version 0.10) import from llama_index directly, use ServiceContext, or build agents with OpenAIAgent and ReActAgent.from_tools. Those APIs are gone or legacy. Current code uses Settings, llama_index.core imports and workflow-based agents such as FunctionAgent.
Example
# pip install llama-index # core + OpenAI LLM and embeddings
# pip install llama-index-llms-ollama llama-index-vector-stores-chroma # extras as needed
import importlib.metadata as md
for pkg in ["llama-index-core", "llama-index-llms-openai", "llama-index-embeddings-openai"]:
try:
print(f"{pkg:32} {md.version(pkg)}")
except md.PackageNotFoundError:
print(f"{pkg:32} not installed")
# llama-index-core 0.14.x
from llama_index.core import VectorStoreIndex, Settings # core classes
from llama_index.llms.openai import OpenAI # an integration packageRemember
- Pipeline: load, index (chunk + embed + store), query
llama-index-coreplus one package per integration- Pre-0.10 imports, ServiceContext and OpenAIAgent are outdated
Watch out for
- Following a 2023 tutorial that uses ServiceContext or
from llama_index import ..., which fails on current versions.