LlamaIndex is a data framework for building LLM applications, primarily focused on RAG (Retrieval-Augmented Generation). It enables connecting LLMs to external data sources via data ingestion, indexing, retrieval, and querying pipelines.
- Version: 0.14.8
- Python: >=3.9, <4.0
- License: MIT
- Package manager:
uv(required for all development)
This is a Python monorepo organized as multiple independent packages:
llama_index/
├── llama-index-core/ # Core framework (required dependency)
├── llama-index-integrations/ # Third-party integrations (300+ packages)
│ ├── llms/ # LLM providers (OpenAI, Anthropic, etc.)
│ ├── embeddings/ # Embedding providers
│ ├── vector_stores/ # Vector databases (Pinecone, Chroma, etc.)
│ ├── readers/ # Data loaders
│ ├── tools/ # Agent tools
│ ├── agent/ # Agent implementations
│ ├── storage/ # Storage backends
│ ├── indices/ # Index types
│ ├── callbacks/ # Callback integrations
│ ├── observability/ # Observability tools
│ └── ...
├── llama-index-packs/ # Pre-built application packs
├── llama-index-utils/ # Utility packages
├── llama-index-finetuning/ # Fine-tuning utilities
├── llama-index-experimental/ # Experimental features
├── llama-index-instrumentation/ # Instrumentation tooling
├── llama-index-cli/ # CLI tools
├── llama-dev/ # Internal monorepo dev CLI
├── llama-datasets/ # Benchmark datasets
├── docs/ # Sphinx documentation
└── scripts/ # Release and utility scripts
# Core imports always use .core. namespace
from llama_index.core.xxx import ClassABC
# Integration imports use the integration's namespace
from llama_index.llms.openai import OpenAI
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.vector_stores.pinecone import PineconeVectorStoreDocument— raw data unit ingested from a data source (text, images, etc.)Node(TextNode, ImageNode, etc.) — atomic chunk of a Document after parsingBaseComponent— Pydantic-based base class for all framework components
| Index | Description |
|---|---|
VectorStoreIndex |
Most common; stores embeddings, retrieves by similarity |
SummaryIndex |
Stores all nodes, retrieves by summarizing |
KeywordTableIndex |
Keyword-based retrieval |
KnowledgeGraphIndex |
Graph-based knowledge storage |
PropertyGraphIndex |
Property graph with typed relations |
DocumentSummaryIndex |
Summary-based document indexing |
Built on top of retrievers; return structured Response objects. Key types:
RetrieverQueryEngine— standard retrieval + synthesisSubQuestionQueryEngine— decomposes queries into sub-questionsRouterQueryEngine— routes queries to appropriate sub-enginesMultiStepQueryEngine— iterative multi-step querying
VectorIndexRetriever,SummaryIndexRetriever, etc.FusionRetriever,AutoMergingRetriever,RouterRetrieverRecursiveRetriever
All LLMs subclass BaseLLM (which extends BaseComponent). Key interface methods:
chat(messages)/achat(messages)— chat completioncomplete(prompt)/acomplete(prompt)— text completionstream_chat(messages)/stream_complete(prompt)— streaming variantsmetadata— property returningLLMMetadata
All embeddings subclass BaseEmbedding. Key interface:
get_text_embedding(text)— single text embeddingget_query_embedding(query)— query-specific embeddingget_text_embedding_batch(texts)— batch embedding
Two primary paradigms:
- ReAct agents — reason-and-act loop
- Workflow agents — structured multi-step execution
Event-driven async framework for building complex pipelines:
Workflow— base class for all workflows@stepdecorator — marks async methods as workflow stepsEvent,StartEvent,StopEvent— typed event passingContext— shared state across steps
Install uv (required):
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | shFrom repo root:
uv sync# Navigate to the package
cd llama-index-integrations/llms/llama-index-llms-openai
# Run tests (uv handles venv automatically)
uv run -- pytest
# Or explicitly create/activate venv
uv venv
source .venv/bin/activate
pytestEach package is independently installable and has its own pyproject.toml. The package under development is auto-installed in editable mode by uv.
# Run tests for a single package
cd llama-index-integrations/llms/llama-index-llms-openai
uv run -- pytest
# Run core tests
make test-core # via pants
# or
cd llama-index-core && uv run -- pytest tests
# Run all changed tests (via llama-dev)
cd llama-dev && uv run -- llama-dev test --base-ref main
# Run with coverage
cd llama-dev && uv run -- llama-dev test --base-ref main --cov --cov-fail-under 50- Minimum test coverage: 50% — PRs will fail if coverage drops below this
- Tests run on Python 3.9, 3.10, 3.11, 3.12 in parallel
- External/remote service integrations must be mocked in unit tests
- Use
pytest-mockfor mocking
Tests live in tests/ within each package, mirroring the source structure:
llama-index-core/
├── llama_index/core/llms/llm.py
└── tests/llms/test_llm.py
| Tool | Purpose |
|---|---|
ruff |
Linting + formatting (primary) |
black |
Code formatting |
mypy |
Static type checking |
codespell |
Spell checking |
pre-commit |
Hook runner |
# From repo root or any package directory
uv run make format # Run black formatter
uv run make lint # Run all linters (pre-commit + mypy)
# Or directly
uv run -- pre-commit run -aConfigured in root pyproject.toml under [tool.ruff]. Key rules:
- Target: Python 3.12 (linting target)
- Notable ignores:
E501(line length),E402(module-level imports),UP(upgrade rules for 3.9 compat) - Docstrings follow Google convention (
[tool.ruff.lint.pydocstyle] convention = "google")
Configured in .pre-commit-config.yaml:
ruff— lint + formatruff-format— formattingcheck-yaml,check-toml,end-of-file-fixer,trailing-whitespacecodespell— spell checking
Each integration follows this layout:
llama-index-integrations/<category>/llama-index-<category>-<name>/
├── pyproject.toml
├── README.md
├── llama_index/
│ └── <category>/
│ └── <name>/
│ ├── __init__.py
│ └── base.py
└── tests/
└── test_<name>.py
[tool.llamahub]
contains_example = false
import_path = "llama_index.<category>.<name>"
[tool.llamahub.class_authors]
ClassName = "author-github-handle"Always bump the version in the integration's pyproject.toml when making changes. The core package (llama-index-core) is exempt from this requirement.
Integration packages should declare:
dependencies = [
"third-party-package>=x.y.z",
"llama-index-core>=0.14.x,<0.15"
]- Self-review performed
- Unit tests added (coverage ≥ 50%)
-
uv run make format; uv run make lintpasses - Version bumped in
pyproject.toml(for integration packages) -
[tool.llamahub]section filled in (for new packages) - README updated for new integrations
- Hard-to-understand code is commented
- Fixes #(issue) — link to the GitHub issue
- Type: bug fix / new feature / breaking change / docs
- Version bump: confirm you bumped the package version
- New package: confirm llamahub metadata filled in
| Workflow | Trigger | Description |
|---|---|---|
unit_test.yml |
PR | Runs tests on Python 3.9–3.12, detects changed packages |
coverage_check.yml |
PR | Enforces 50% coverage threshold |
lint.yml |
push/PR | Runs pre-commit run -a |
core-typecheck.yml |
PR | Runs mypy on core |
build_package.yml |
push | Builds packages |
publish_sub_package.yml |
release | Publishes to PyPI |
The CI uses llama-dev (from llama-dev/) to automatically detect which packages changed relative to the base branch and only run tests for affected packages and their dependents.
All framework components use Pydantic v2 (pydantic>=2.8.0). Import via the bridge:
from llama_index.core.bridge.pydantic import BaseModel, Field, field_validatorNever import directly from pydantic in core or integration code — use the bridge.
LlamaIndex provides both sync and async variants for all key operations. Async methods are prefixed with a:
# Sync
response = index.as_query_engine().query("...")
# Async
response = await index.as_query_engine().aquery("...")Use nest_asyncio (already a dependency) when running async in notebooks.
- All functions must be type-annotated (
mypy disallow_untyped_defs = true) - Use
typing_extensionsfor compatibility with Python 3.9 - Avoid
UPrules (type alias upgrades) to maintain 3.9 compatibility
Use llama_index.core.instrumentation for telemetry/tracing:
from llama_index.core.instrumentation import DispatcherSpanMixinLegacy callback system available via llama_index.core.callbacks.
Central object for managing all storage backends:
from llama_index.core import StorageContext
storage_context = StorageContext.from_defaults(
docstore=...,
index_store=...,
vector_store=...,
)python_version = "3.9"ignore_missing_imports = truedisallow_untyped_defs = true- Excludes:
_static,build,examples,notebooks,venv - Uses
pydantic.mypyplugin
Skip list (do not fix): astroid, gallary, momento, narl, ot, rouge
Skipped paths: examples/, experimental/, *.csv, *.html, *.json, *.jsonl, *.pdf, *.txt, *.ipynb
# Setup global dev environment
uv sync
# Format code
uv run make format
# Lint everything
uv run make lint
# Run core tests
cd llama-index-core && uv run -- pytest tests/
# Run tests for changed packages only
cd llama-dev && uv run -- llama-dev test --base-ref main --workers 8
# Run with coverage
cd llama-dev && uv run -- llama-dev test --base-ref main --cov --cov-fail-under 50
# Get info on a package
cd llama-dev && uv run -- llama-dev pkg info llama-index-core
# Run a command across all packages
cd llama-dev && uv run -- llama-dev pkg exec --cmd "uv sync" --all
# Build docs
uv run make watch-docs- Documentation
- LlamaHub — integration registry
- Discord
- GitHub Issues