LLM framework to build customizable, production-ready LLM applications with pipelines connecting models, vector DBs, and data processors.
—
Pre-built and custom pipeline templates for orchestrating component workflows including QA, search, generation, and indexing pipelines.
from haystack import Pipeline
from haystack.pipelines import ExtractiveQAPipeline, GenerativeQAPipeline, DocumentSearchPipelinefrom haystack import Pipeline
from haystack.nodes.base import BaseComponent
from typing import Dict, List, Any, Optional
class Pipeline:
def __init__(self):
"""Initialize an empty pipeline."""
def add_node(self, component: BaseComponent, name: str, inputs: List[str]) -> None:
"""
Add a component to the pipeline.
Args:
component: Component instance to add
name: Unique name for the component in pipeline
inputs: List of input names this component receives from
"""
def run(self, query: Optional[str] = None, file_paths: Optional[List[str]] = None,
labels: Optional[List] = None, documents: Optional[List] = None,
meta: Optional[Dict[str, Any]] = None, **kwargs) -> Dict[str, Any]:
"""
Run the pipeline with given inputs.
Args:
query: Query string for QA/search pipelines
file_paths: File paths for indexing pipelines
labels: Labels for evaluation pipelines
documents: Documents for processing
meta: Additional metadata
Returns:
Dictionary with pipeline results
"""from haystack.pipelines import ExtractiveQAPipeline
from haystack.nodes.reader.base import BaseReader
from haystack.nodes.retriever.base import BaseRetriever
class ExtractiveQAPipeline(Pipeline):
def __init__(self, reader: BaseReader, retriever: BaseRetriever):
"""
Initialize extractive QA pipeline.
Args:
reader: Reader component for answer extraction
retriever: Retriever component for document retrieval
"""from haystack.pipelines import GenerativeQAPipeline
class GenerativeQAPipeline(Pipeline):
def __init__(self, generator, retriever):
"""
Initialize generative QA pipeline.
Args:
generator: Generator component for answer generation
retriever: Retriever component for document retrieval
"""from haystack.pipelines import DocumentSearchPipeline
class DocumentSearchPipeline(Pipeline):
def __init__(self, retriever: BaseRetriever):
"""
Initialize document search pipeline.
Args:
retriever: Retriever component for document search
"""Install with Tessl CLI
npx tessl i tessl/pypi-farm-haystack