CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-llama-index

Interface between LLMs and your data for building retrieval-augmented generation (RAG) applications

Pending
Overview
Eval results
Files

query-processing.mddocs/

Query Processing

Query engines that orchestrate retrieval and response generation, supporting various strategies from basic retrieval to complex multi-step reasoning and routing.

Capabilities

Basic Query Engines

Core query engines that combine retrieval with response synthesis for question-answering.

class RetrieverQueryEngine:
    """
    Standard retrieval-based query engine.
    
    Args:
        retriever: Retriever to use for document retrieval
        response_synthesizer: Synthesizer for generating responses
        node_postprocessors: List of node postprocessors
        callback_manager: Callback manager for event handling
    """
    def __init__(self, retriever, response_synthesizer=None, node_postprocessors=None, callback_manager=None): ...
    
    def query(self, str_or_query_bundle):
        """
        Query the engine.
        
        Args:
            str_or_query_bundle: Query string or QueryBundle object
            
        Returns:
            Response: Query response with sources
        """
    
    async def aquery(self, str_or_query_bundle):
        """Async version of query."""

class CitationQueryEngine:
    """
    Query engine that provides source citations in responses.
    
    Args:
        retriever: Retriever for document retrieval
        response_synthesizer: Synthesizer that includes citations
        **kwargs: Additional arguments
    """
    def __init__(self, retriever, response_synthesizer=None, **kwargs): ...
    
    def query(self, str_or_query_bundle):
        """Query with citation support."""

class RetryQueryEngine:
    """
    Query engine with retry logic for failed queries.
    
    Args:
        query_engine: Base query engine to wrap
        evaluator: Evaluator to determine if retry is needed
        max_retries: Maximum number of retry attempts
    """
    def __init__(self, query_engine, evaluator, max_retries=3): ...
    
    def query(self, str_or_query_bundle):
        """Query with automatic retry on failure."""

Advanced Query Engines

Sophisticated query engines for complex reasoning and multi-step operations.

class RouterQueryEngine:
    """
    Routes queries to different query engines based on query content.
    
    Args:
        selector: Selector to choose appropriate query engine
        query_engines: List of available query engines
        **kwargs: Additional arguments
    """
    def __init__(self, selector, query_engines, **kwargs): ...
    
    def query(self, str_or_query_bundle):
        """Route query to appropriate engine."""

class SubQuestionQueryEngine:
    """
    Breaks complex queries into sub-questions for better handling.
    
    Args:
        question_gen: Question generator for creating sub-questions
        query_engines: List of query engines for sub-questions
        response_synthesizer: Synthesizer for combining sub-answers
        **kwargs: Additional arguments
    """
    def __init__(self, question_gen, query_engines, response_synthesizer=None, **kwargs): ...
    
    def query(self, str_or_query_bundle):
        """Query using sub-question decomposition."""

class MultiStepQueryEngine:
    """
    Multi-step query engine for complex reasoning tasks.
    
    Args:
        query_engine: Base query engine
        query_transform: Transform for iterative refinement
        index_summary: Summary of the index being queried
        **kwargs: Additional arguments
    """
    def __init__(self, query_engine, query_transform, index_summary=None, **kwargs): ...
    
    def query(self, str_or_query_bundle):
        """Execute multi-step reasoning."""

Specialized Query Engines

Query engines for specific data types and use cases.

class TransformQueryEngine:
    """
    Query engine with query transformation capabilities.
    
    Args:
        query_engine: Base query engine to wrap
        query_transform: Transform to apply to queries
        transform_metadata: Additional metadata for transformation
    """
    def __init__(self, query_engine, query_transform, transform_metadata=None): ...
    
    def query(self, str_or_query_bundle):
        """Query with transformation."""

class ComposableGraphQueryEngine:
    """
    Query engine for composable graphs combining multiple indices.
    
    Args:
        graph: ComposableGraph to query
        custom_query_engines: Custom query engines for specific indices
        **kwargs: Additional arguments
    """
    def __init__(self, graph, custom_query_engines=None, **kwargs): ...
    
    def query(self, str_or_query_bundle):
        """Query across multiple indices."""

Pandas Integration

Query engines for natural language queries over pandas DataFrames.

class PandasQueryEngine:
    """
    Natural language query engine for pandas DataFrames.
    
    Args:
        df: Pandas DataFrame to query
        instruction_str: Instructions for query interpretation
        **kwargs: Additional arguments
    """
    def __init__(self, df, instruction_str=None, **kwargs): ...
    
    def query(self, str_or_query_bundle):
        """
        Execute natural language query on DataFrame.
        
        Args:
            str_or_query_bundle: Natural language query
            
        Returns:
            Response: Query results with DataFrame operations
        """

SQL Integration

Query engines for natural language to SQL translation and execution.

class NLSQLTableQueryEngine:
    """
    Natural language to SQL query engine.
    
    Args:
        sql_database: SQL database wrapper
        tables: List of table names to query
        **kwargs: Additional arguments
    """
    def __init__(self, sql_database, tables=None, **kwargs): ...
    
    def query(self, str_or_query_bundle):
        """
        Execute natural language SQL query.
        
        Args:
            str_or_query_bundle: Natural language query
            
        Returns:
            Response: Query results from database
        """

Response Synthesizers

Components that generate coherent responses from retrieved context.

def get_response_synthesizer(response_mode="compact", **kwargs):
    """
    Factory function for creating response synthesizers.
    
    Args:
        response_mode: Synthesis mode ("refine", "compact", "tree_summarize", "simple_summarize")
        **kwargs: Additional arguments
        
    Returns:
        BaseSynthesizer: Response synthesizer instance
    """

class TreeSummarize:
    """Tree-based response synthesis with hierarchical summarization."""
    def __init__(self, **kwargs): ...
    
    def synthesize(self, query, nodes, **kwargs):
        """Synthesize response using tree summarization."""

class Refine:
    """Iterative response refinement synthesis."""
    def __init__(self, **kwargs): ...
    
    def synthesize(self, query, nodes, **kwargs):
        """Synthesize response using iterative refinement."""

class CompactAndRefine:
    """Compact context then refine response."""
    def __init__(self, **kwargs): ...
    
    def synthesize(self, query, nodes, **kwargs):
        """Synthesize response with compacting and refinement."""

class SimpleSummarize:
    """Simple concatenation-based synthesis."""
    def __init__(self, **kwargs): ...
    
    def synthesize(self, query, nodes, **kwargs):
        """Synthesize response with simple concatenation."""

Query Bundle

class QueryBundle:
    """
    Query representation with optional embeddings.
    
    Args:
        query_str: Query string
        image_path: Optional image path for multimodal queries
        embedding: Optional query embedding
        custom_embedding_strs: Custom strings for embedding
    """
    def __init__(self, query_str, image_path=None, embedding=None, custom_embedding_strs=None): ...
    
    @property
    def query_str(self):
        """Query string."""
    
    @property
    def embedding(self):
        """Query embedding vector."""

Response Schema

class Response:
    """
    Response object with source tracking.
    
    Args:
        response: Response text
        source_nodes: List of source nodes used
        metadata: Additional response metadata
    """
    def __init__(self, response=None, source_nodes=None, metadata=None): ...
    
    @property
    def response(self):
        """Response text."""
    
    @property
    def source_nodes(self):
        """Source nodes used for response."""
    
    def get_formatted_sources(self, length=100):
        """
        Get formatted source text.
        
        Args:
            length: Maximum length per source
            
        Returns:
            str: Formatted source information
        """

Install with Tessl CLI

npx tessl i tessl/pypi-llama-index

docs

agents-workflows.md

data-indexing.md

document-processing.md

index.md

llm-integration.md

prompts.md

query-processing.md

response-synthesis.md

retrievers.md

storage-settings.md

tile.json