haystack

deepset-aiApache-2.0活跃维护

开源 LLM 应用编排框架,用模块化管道和智能体工作流显式控制检索、路由、记忆与生成,适合搭建 RAG、语义搜索和多模态对话系统。

Open-source AI orchestration framework for building context-engineered, production-ready LLM applications. Design modular pipelines and agent workflows with explicit control over retrieval, routing, memory, and generation. Built for scalable agents, RAG, multimodal applications, semantic search, and conversational systems.

v2.31.1发布于 2026-11-03 09:27 UTC26,970star +28 / 7 天3,415fork同步于 2026-11-10 05:21 UTC

怎么上手

由 README 提炼,执行前请确认
pip install haystack-ai
硬件要求按 README 说明

README 未说明显存或 GPU 要求;框架本身为 Python 库,模型可接本地或云端,实际硬件取决于所选模型与后端。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Python 开源 AI 编排框架,用模块化 Pipeline 和 Agent 构建可控的 RAG 与检索应用

开源 LLM 应用编排框架,用模块化管道和智能体工作流显式控制检索、路由、记忆与生成,适合搭建 RAG、语义搜索和多模态对话系统。

核心能力

  • 用 Pipeline 显式控制检索、路由、记忆与生成
  • Agent 支持 before_llm、before_tool 等生命周期钩子
  • 同一 Pipeline 同步或异步运行并逐 token 流式输出
  • 内置 step_count、token_usage 与工具调用追踪
  • 模型与厂商无关,可切换 OpenAI、Anthropic、本地模型等

容易踩的坑

需自行接入并配置模型提供方(如 OpenAI、本地模型)才能跑通;把 Pipeline 部署为 REST API 或 MCP 服务需另装 Hayhooks;默认会收集匿名组件初始化遥测,可在文档中查看如何关闭

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.31.1
  1. v3.5.0-rc1pre-release2026-11-09 · 2026-11-09 12:38 UTC
    查看更新说明

    ⭐️ Highlights

    🧭 Classify and Route with the OpenAI Decisions API

    Three new components use the OpenAI Decisions API to make choices about your data without writing a prompt. OpenAIDecisionsTextRouter sends text to a named output per label, OpenAIDecisionsImageRouter does the same for images and can send low-confidence decisions to a fallback branch, and OpenAIDecisionsDocumentClassifier answers choice, score, and yes/no questions about documents and stores the answers in their metadata.

    from haystack.components.routers import OpenAIDecisionsTextRouter
    
    router = OpenAIDecisionsTextRouter(
        labels={
            "billing": "Payments, invoices, refunds and charges",
            "technical": "Bugs, crashes and errors in the product",
        },
        instructions="Which team should handle this support request?",
        min_confidence=0.6,
    )
    
    print(router.run(text="I was charged twice for my subscription."))
    # >> {'billing': 'I was charged twice for my subscription.'}
    

    🧱 Structured Output for Agents

    The new StructuredOutputHook validates the Agent's final reply against a Pydantic model or JSON schema and returns it as a dict in result["structured_output"]. If the reply doesn't validate, the hook sends the error back to the model and lets it try again, up to max_retries times.

    from pydantic import BaseModel
    
    from haystack.components.agents import Agent
    from haystack.components.generators.chat import OpenAIResponsesChatGenerator
    from haystack.dataclasses import ChatMessage
    from haystack.hooks.structured_output import StructuredOutputHook
    
    
    class CityInfo(BaseModel):
        city: str
        country: str
    
    
    agent = Agent(
        chat_generator=OpenAIResponsesChatGenerator(generation_kwargs={"text_format": CityInfo}),
        state_schema={"structured_output": {"type": dict}},
        hooks={"on_exit": [StructuredOutputHook(schema=CityInfo)]},
    )
    
    result = agent.run(messages=[ChatMessage.from_user("Which city is the Eiffel Tower in?")])
    print(result["structured_output"])
    # >> {'city': 'Paris', 'country': 'France'}
    

    Also new for Agents: the experimental StepBudgetReminderHook tells the model how many steps it has left as it approaches max_agent_steps, so it wraps up with an answer instead of being cut off.

    🎯 Multivector Embeddings and MaxSimRanker

    Document has a new multivector_embedding field for late-interaction models such as ColBERT, and the new MaxSimRanker reranks candidates by comparing each query vector to the document vectors and summing the best matches. DocumentJoiner(join_mode="merge_embeddings") can also combine dense, sparse, and multivector embeddings computed in parallel for the same documents.

    This is the first step toward multivector retrieval in Haystack (#13257). Embedders that produce multivector embeddings are in progress in Haystack Core Integrations: Sentence Transformers and vLLM.

    from haystack import Document
    from haystack.components.rankers import MaxSimRanker
    
    # Representative multivector embedding for "How do solar panels work?"
    query_multivector_embedding = [[1.0, 0.0], [0.0, 1.0]]
    
    documents = [
        Document(content="Wind turbines generate electricity.", multivector_embedding=[[1.0, 0.0], [0.0, 0.2]]),
        Document(content="Solar panels turn sunlight into power.", multivector_embedding=[[0.95, 0.05], [0.15, 0.9]]),
        Document(content="Solar cells absorb light.", multivector_embedding=[[0.9, 0.1], [0.1, 0.9]]),
    ]
    
    ranker = MaxSimRanker(top_
    
  2. v2.31.1最新正式版2026-11-03 · 2026-11-03 09:27 UTC

    🔒 Security Notes

    • Haystack now requires anyio>=4.14.2. anyio is installed transitively through httpx and openai; versions before 4.14.2 are affected by CVE-2026-63374 (GHSA-82r6-8w77-94w6).
    • Haystack now requires certifi>=2026.10.19. certifi is installed transitively through httpx and posthog; earlier versions trust eMudhra/emSign certificate authorities whose private keys were compromised (GHSA-6q48-6c7w-9gw2). If you pin certifi, raise the pin to at least 2026.10.19.
  3. v2.31.1-rc1pre-release2026-11-02 · 2026-11-02 16:51 UTC

    这个版本没有写更新说明。

  4. v3.4.12026-10-21 · 2026-10-21 19:10 UTC
    查看更新说明

    🔒 Security Notes

    • Haystack now requires certifi>=2026.10.19. certifi is installed transitively through httpx and posthog; earlier versions trust eMudhra/emSign certificate authorities whose private keys were compromised (GHSA-6q48-6c7w-9gw2). If you pin certifi, raise the pin to at least 2026.10.19.
  5. v3.4.1-rc2pre-release2026-10-21 · 2026-10-21 18:54 UTC

    这个版本没有写更新说明。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译
    CI/CDTests types - Mypy Coverage badge Ruff
    DocsWebsite
    PackagePyPI PyPI - Downloads PyPI - Python Version Conda Version GitHub License Compliance HVTrust Evidence Grade OpenSSF Best Practices
    MetaDiscord Twitter Follow

    Haystack is an open-source AI orchestration framework for building production-ready LLM applications in Python.

    Design modular pipelines and agent workflows with explicit control over retrieval, routing, memory, and generation. Build scalable RAG systems, multimodal applications, semantic search, question answering, and autonomous agents, all in a transparent architecture that lets you experiment, customize deeply, and deploy with confidence.

    Table of Contents

    Installation

    The simplest way to get Haystack is via pip:

    pip install haystack-ai
    

    Install nightly pre-releases to try the newest features:

    pip install --pre haystack-ai
    

    Haystack supports multiple installation methods, including Docker images. For a comprehensive guide, please refer to the documentation.

    Documentation

    If you're new to the project, check out "What is Haystack?" then go through the "Get Started Guide" and build your first LLM application in a matter of minutes. Keep learning with the tutorials. For more advanced use cases, or just to get some inspiration, you can browse our Haystack recipes in the Cookbook.

    At any given point, hit the documentation to learn more about Haystack, what it can do for you, and the technology behind.

    Features

    Agents built for production
    Extend agent behavior with lifecycle hooks (before_llm, before_tool, on_exit, …) for guardrails and custom logic, and track step_count, token_usage, and tool calls out of the box for monitoring and cost control. Get started fast with ready-made agents from Agent Pack (e.g., a deep research agent, or an advanced RAG agent) or give your own agents progressive skill discovery via SkillToolset, so skill descriptions only enter context when needed.

    Built for context engineering
    Design flexible systems with explicit control over how information is retrieved, ranked, filtered, combined, structured, and routed before it reaches the model. Define pipelines and agent workflows where retrieval, memory, tools, and generation are transparent and traceable.

    Native Async Support
    One Pipeline runs synchronously or asynchronously and streams token by token. Agent can run concurrent tool calls.

    Modular and customizable
    Use built-in components for retrieval, indexing, tool calling, memory, and evaluation, or create your own. Add loops, branches, and conditional logic to precisely control how context moves through your pipelines and agent workflows.

    Model- and vendor-agnostic
    Integrate with OpenAI, Mistral, Anthropic, Cohere, Hugging Face, Google, Azure OpenAI, AWS Bedrock, local models, and many others. Swap models or infrastructure components without rewriting your system.

    Extensible ecosystem
    Build and share custom components through a consistent interface that makes it easy for the community and third parties to extend Haystack and contribute to an open ecosystem.

    [!TIP]

    Would you like to deploy and serve Haystack pipelines as REST APIs or MCP servers? Hayhooks provides a simple way for you to wrap pipelines and agents with custom logic and expose them through HTTP endpoints or MCP. It also supports OpenAI-compatible chat completion endpoints and works with chat UIs like open-webui.

    Haystack Enterprise: Support & Platform

    Get expert support from the Haystack team, build faster with enterprise-grade templates, and scale securely with deployment guides for cloud and on-prem environments with Haystack Enterprise Starter. Read more about it in the announcement post.

    👉 Get Haystack Enterprise Starter

    Need a managed production setup for Haystack? The Haystack Enterprise Platform helps you build, test, deploy and operate Haystack pipelines with built-in observability, collaboration, governance, and access controls. It’s available as a managed cloud service or as a self-hosted solution.

    👉 Learn more about Haystack Enterprise Platform or try it free

    Telemetry

    Haystack collects anonymous usage statistics of pipeline components. We receive an event every time these components are initialized. This way, we know which components are most relevant to our community.

    Read more about telemetry in Haystack or how you can opt out in Haystack docs.

    🖖 Community

    If you have a feature request or a bug report, feel free to open an issue in GitHub. We regularly check these, so you can expect a quick response. If you'd like to discuss a topic or get more general advice on how to make Haystack work for your project, you can start a thread in Github Discussions or our Discord channel. We also check 𝕏 (Twitter) and Stack Overflow.

    Contributing to Haystack

    We are very open to the community's contributions - be it a quick fix of a typo, or a completely new feature! You don't need to be a Haystack expert to provide meaningful improvements. To learn how to get started, check out our Contributor Guidelines first.

    There are several ways you can contribute to Haystack:

    [!TIP] 👉 Check out the full list of issues that are open to contributions

    Organizations using Haystack

    Haystack is used by thousands of teams building production AI systems across industries, including:

    Are you also using Haystack? Open a PR or tell us your story