Interface between LLMs and your data for building retrieval-augmented generation (RAG) applications
—
Data structures for organizing and retrieving information efficiently, supporting various indexing strategies from vector-based semantic search to hierarchical trees and knowledge graphs.
Vector-based index for semantic search using embeddings, supporting various vector databases and similarity metrics.
class VectorStoreIndex:
"""
Vector store index for semantic search.
Args:
nodes: List of Node objects to index
storage_context: Storage configuration
service_context: Service configuration (deprecated, use Settings)
**kwargs: Additional arguments
"""
def __init__(self, nodes=None, storage_context=None, service_context=None, **kwargs): ...
@classmethod
def from_documents(cls, documents, storage_context=None, service_context=None, **kwargs):
"""
Create index from documents.
Args:
documents: List of Document objects
storage_context: Storage configuration
service_context: Service configuration (deprecated)
**kwargs: Additional arguments
Returns:
VectorStoreIndex: Constructed index
"""
def as_query_engine(self, **kwargs):
"""
Create query engine from index.
Returns:
BaseQueryEngine: Query engine for the index
"""
def as_retriever(self, similarity_top_k=None, **kwargs):
"""
Create retriever from index.
Args:
similarity_top_k: Number of similar documents to retrieve
Returns:
BaseRetriever: Retriever for the index
"""
def insert(self, document, **kwargs):
"""Insert a document into the index."""
def delete_ref_doc(self, ref_doc_id, **kwargs):
"""Delete document by reference ID."""
def update_ref_doc(self, document, **kwargs):
"""Update document in the index."""Simple list-based index for summarization tasks, storing all nodes in a flat list structure.
class SummaryIndex:
"""
Summary index for basic retrieval and summarization.
Args:
nodes: List of Node objects to index
storage_context: Storage configuration
**kwargs: Additional arguments
"""
def __init__(self, nodes=None, storage_context=None, **kwargs): ...
@classmethod
def from_documents(cls, documents, storage_context=None, **kwargs):
"""Create summary index from documents."""
def as_query_engine(self, retriever_mode="default", **kwargs):
"""
Create query engine from index.
Args:
retriever_mode: Retrieval mode ("default", "embedding")
"""
def as_retriever(self, retriever_mode="default", **kwargs):
"""Create retriever from index."""Property graph index for complex entity relationships with support for knowledge graph reasoning and graph-based retrieval.
class PropertyGraphIndex:
"""
Property graph index for knowledge graph storage and retrieval.
Args:
nodes: List of Node objects to index
property_graph_store: Graph storage backend
vector_store: Vector storage for embeddings
embed_model: Embedding model for nodes
**kwargs: Additional arguments
"""
def __init__(
self,
nodes=None,
property_graph_store=None,
vector_store=None,
embed_model=None,
**kwargs
): ...
@classmethod
def from_documents(cls, documents, **kwargs):
"""Create property graph index from documents."""
def as_query_engine(self, **kwargs):
"""Create query engine for graph traversal and reasoning."""
def as_retriever(self, **kwargs):
"""Create retriever for graph-based document retrieval."""
def upsert_triplet(self, subj, pred, obj):
"""Insert or update a knowledge triplet."""
def delete_triplet(self, subj, pred, obj):
"""Delete a knowledge triplet."""Keyword-based index for exact keyword matching and retrieval, supporting various keyword extraction algorithms.
class KeywordTableIndex:
"""
Base keyword table index for keyword-based retrieval.
Args:
nodes: List of Node objects to index
table: Index table storage
**kwargs: Additional arguments
"""
def __init__(self, nodes=None, table=None, **kwargs): ...
@classmethod
def from_documents(cls, documents, **kwargs):
"""Create keyword index from documents."""
class SimpleKeywordTableIndex(KeywordTableIndex):
"""
Simple keyword extraction using basic text processing.
Args:
max_keywords_per_chunk: Maximum keywords per document chunk
keyword_extract_template: Template for keyword extraction
**kwargs: KeywordTableIndex arguments
"""
def __init__(
self,
max_keywords_per_chunk=10,
keyword_extract_template=None,
**kwargs
): ...
class RAKEKeywordTableIndex(KeywordTableIndex):
"""
RAKE (Rapid Automatic Keyword Extraction) algorithm for keyword extraction.
Args:
max_keywords_per_chunk: Maximum keywords per document chunk
**kwargs: KeywordTableIndex arguments
"""
def __init__(self, max_keywords_per_chunk=10, **kwargs): ...Vector index supporting multimodal data including text, images, and other media types with cross-modal similarity search.
class MultiModalVectorStoreIndex:
"""
Multimodal vector store index for text and image data.
Args:
nodes: List of Node objects (text and image)
image_vector_store: Vector store for image embeddings
storage_context: Storage configuration
**kwargs: Additional arguments
"""
def __init__(
self,
nodes=None,
image_vector_store=None,
storage_context=None,
**kwargs
): ...
@classmethod
def from_documents(cls, documents, **kwargs):
"""Create multimodal index from text and image documents."""
def as_query_engine(self, **kwargs):
"""Create multimodal query engine."""
def as_retriever(self, **kwargs):
"""Create multimodal retriever."""Container for combining multiple indices with routing and composition strategies for complex retrieval scenarios.
class ComposableGraph:
"""
Composable graph for combining multiple indices.
Args:
all_indices: Dictionary mapping index IDs to index objects
root_id: Root index identifier
**kwargs: Additional arguments
"""
def __init__(self, all_indices, root_id=None, **kwargs): ...
@classmethod
def from_indices(
cls,
root_index,
children_indices,
index_summaries=None,
**kwargs
):
"""
Create composable graph from indices.
Args:
root_index: Main index for routing
children_indices: List of child indices
index_summaries: Summaries for each child index
"""
def as_query_engine(self, **kwargs):
"""Create query engine with index routing."""
def as_retriever(self, **kwargs):
"""Create retriever with index selection."""Specialized indices for structured data sources like SQL databases and pandas DataFrames.
class SQLStructStoreIndex:
"""
SQL-based structured store index.
Args:
nodes: List of structured nodes
sql_database: SQL database connection
table_name: Target table name
**kwargs: Additional arguments
"""
def __init__(
self,
nodes=None,
sql_database=None,
table_name=None,
**kwargs
): ...
@classmethod
def from_documents(cls, documents, sql_database, **kwargs):
"""Create SQL index from documents."""
class PandasIndex:
"""
Pandas DataFrame index for structured data analysis.
Args:
df: Pandas DataFrame
**kwargs: Additional arguments
"""
def __init__(self, df=None, **kwargs): ...
def as_query_engine(self, **kwargs):
"""Create query engine for DataFrame operations."""Hierarchical tree-based index for structured retrieval, organizing nodes in a tree structure for efficient traversal.
class TreeIndex:
"""
Tree index for hierarchical retrieval.
Args:
nodes: List of Node objects to index
storage_context: Storage configuration
**kwargs: Additional arguments
"""
def __init__(self, nodes=None, storage_context=None, **kwargs): ...
@classmethod
def from_documents(cls, documents, storage_context=None, **kwargs):
"""Create tree index from documents."""
def as_query_engine(self, retriever_mode="select_leaf_embedding", **kwargs):
"""
Create query engine from index.
Args:
retriever_mode: Tree traversal mode
"""
def as_retriever(self, retriever_mode="select_leaf_embedding", **kwargs):
"""Create retriever from index."""Keyword-based index using various extraction strategies for term-based retrieval.
class KeywordTableIndex:
"""Base class for keyword table indices."""
def __init__(self, nodes=None, storage_context=None, **kwargs): ...
@classmethod
def from_documents(cls, documents, storage_context=None, **kwargs):
"""Create keyword index from documents."""
class SimpleKeywordTableIndex(KeywordTableIndex):
"""Simple keyword extraction and matching."""
class RAKEKeywordTableIndex(KeywordTableIndex):
"""RAKE algorithm-based keyword extraction."""Graph-based index for representing entities and relationships, enabling complex relational queries.
class KnowledgeGraphIndex:
"""
Knowledge graph index for entity-relationship modeling.
Args:
nodes: List of Node objects to index
storage_context: Storage configuration
kg_triple_extract_template: Template for triple extraction
**kwargs: Additional arguments
"""
def __init__(self, nodes=None, storage_context=None, kg_triple_extract_template=None, **kwargs): ...
@classmethod
def from_documents(cls, documents, storage_context=None, **kwargs):
"""Create knowledge graph index from documents."""
def as_query_engine(self, **kwargs):
"""Create query engine for graph queries."""
def as_retriever(self, **kwargs):
"""Create retriever for graph-based retrieval."""Advanced graph index with entity and relationship properties for complex graph operations.
class PropertyGraphIndex:
"""
Property graph index with rich entity/relationship properties.
Args:
nodes: List of Node objects to index
storage_context: Storage configuration
**kwargs: Additional arguments
"""
def __init__(self, nodes=None, storage_context=None, **kwargs): ...
@classmethod
def from_documents(cls, documents, storage_context=None, **kwargs):
"""Create property graph index from documents."""
def as_query_engine(self, **kwargs):
"""Create query engine for property graph queries."""
def as_retriever(self, **kwargs):
"""Create retriever for property graph retrieval."""Index that maintains document-level summaries for efficient high-level retrieval.
class DocumentSummaryIndex:
"""
Document summary index for document-level retrieval.
Args:
nodes: List of Node objects to index
storage_context: Storage configuration
response_synthesizer: Synthesizer for generating summaries
**kwargs: Additional arguments
"""
def __init__(self, nodes=None, storage_context=None, response_synthesizer=None, **kwargs): ...
@classmethod
def from_documents(cls, documents, storage_context=None, **kwargs):
"""Create document summary index from documents."""
def as_query_engine(self, **kwargs):
"""Create query engine for document-level queries."""
def as_retriever(self, **kwargs):
"""Create retriever for document-level retrieval."""Combine multiple indices into a unified query interface for complex multi-index operations.
class ComposableGraph:
"""
Composable graph for combining multiple indices.
Args:
all_indices: Dictionary mapping index IDs to indices
index_summaries: Dictionary mapping index IDs to summaries
**kwargs: Additional arguments
"""
def __init__(self, all_indices, index_summaries=None, **kwargs): ...
def as_query_engine(self, **kwargs):
"""Create query engine for multi-index queries."""
def as_retriever(self, **kwargs):
"""Create retriever for multi-index retrieval."""def load_index_from_storage(storage_context, index_id=None, **kwargs):
"""
Load index from storage.
Args:
storage_context: Storage context containing persisted index
index_id: Optional index ID to load specific index
Returns:
BaseIndex: Loaded index
"""
def load_indices_from_storage(storage_context, index_ids=None, **kwargs):
"""
Load multiple indices from storage.
Args:
storage_context: Storage context
index_ids: List of index IDs to load
Returns:
dict: Dictionary mapping index IDs to loaded indices
"""
def load_graph_from_storage(storage_context, root_id=None, **kwargs):
"""
Load composable graph from storage.
Args:
storage_context: Storage context
root_id: Root node ID for the graph
Returns:
ComposableGraph: Loaded composable graph
"""from enum import Enum
class IndexStructType(Enum):
"""Enumeration of available index types."""
TREE = "tree"
LIST = "list"
KEYWORD_TABLE = "keyword_table"
VECTOR_STORE = "vector_store"
DOCUMENT_SUMMARY = "document_summary"
KNOWLEDGE_GRAPH = "kg"
PROPERTY_GRAPH = "property_graph"Install with Tessl CLI
npx tessl i tessl/pypi-llama-index