Implementation:Run llama Llama index Download Pack
| Knowledge Sources | |
|---|---|
| Domains | Download, Pack |
| Last Updated | 2026-02-11 19:00 GMT |
Overview
Provides functions for downloading LlamaPack templates from the llama_index packs repository, installing their dependencies, and dynamically loading them into memory.
Description
The download/pack.py module handles the retrieval of LlamaPack templates from the llama-index-packs directory within the main llama_index GitHub repository. Unlike the general module downloader, this module is specifically designed for the newer pack template format that uses pyproject.toml for dependency management.
The download workflow consists of two key functions:
- download_module_and_reqs takes the local and remote directory paths along with a package name and sub-module name. It recursively discovers all source files under the pack's namespace (llama_index/packs/{sub_module}) using get_source_files_recursive, downloads each file, and writes them to the local directory. It then downloads the pack's pyproject.toml and creates a minimal README.md (required for pip install from pyproject.toml). Finally, it installs the pack's dependencies by running pip install . in the pack directory using a ChangeDirectory context manager.
- download_llama_pack_template is the primary entry point. It converts a package name (e.g., "llama-index-packs-resume-screener") into a Python sub-module name by stripping the prefix and replacing hyphens with underscores. It calls download_module_and_reqs and then dynamically loads the module using importlib to return the requested pack class.
The module also provides track_download for sending analytics events to the LlamaHub proxy server.
Usage
Use this module when you need to download a LlamaPack template for customization or direct use. This is the backend for the download_llama_pack convenience function and the llamaindex-cli download-llamapack CLI command. It is particularly useful when you want a complete, editable copy of a pack template rather than just installing it as a dependency.
Code Reference
Source Location
- Repository: Run_llama_Llama_index
- File: llama-index-core/llama_index/core/download/pack.py
Signature
def download_llama_pack_template(
new_install_parent: str,
llama_pack_class: str,
llama_pack_url: str = LLAMA_PACKS_CONTENTS_URL,
llama_pack_source_files_dir_path: str = LLAMA_PACKS_SOURCE_FILES_GITHUB_TREE_URL,
refresh_cache: bool = False,
custom_dir: Optional[str] = None,
custom_path: Optional[str] = None,
base_file_name: str = "__init__.py",
) -> Any
Import
from llama_index.core.download.pack import download_llama_pack_template
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| new_install_parent | str | Yes | The pip package name of the pack (e.g., "llama-index-packs-resume-screener"). |
| llama_pack_class | str | Yes | The Python class name of the pack to load (e.g., "ResumeScreenerPack"). |
| llama_pack_url | str | No | Base URL for pack raw content on GitHub. Defaults to the llama-index-packs directory. |
| llama_pack_source_files_dir_path | str | No | GitHub tree URL for enumerating source files. Defaults to the llama_index main branch tree URL. |
| refresh_cache | bool | No | If True, skips local cache and re-downloads from remote. Defaults to False. |
| custom_dir | Optional[str] | No | Custom directory name under the parent folder for downloads. |
| custom_path | Optional[str] | No | Custom absolute directory path for downloads. |
| base_file_name | str | No | Entry point file name for the pack. Defaults to "__init__.py". |
Outputs
| Name | Type | Description |
|---|---|---|
| result | Any | The downloaded LlamaPack class, ready to be instantiated. |
Usage Examples
from llama_index.core.download.pack import download_llama_pack_template
# Download a LlamaPack template
ResumeScreenerPack = download_llama_pack_template(
new_install_parent="llama-index-packs-resume-screener",
llama_pack_class="ResumeScreenerPack",
)
# Instantiate and use the pack
pack = ResumeScreenerPack(resume_path="resume.pdf")
response = pack.run(query="What are the candidate's skills?")