# Haystack — Open-Source RAG & Agent Framework > Production-ready Python framework for building RAG pipelines, search systems, and AI agents with composable components. By deepset. Supports 30+ integrations. 20,000+ GitHub stars. ## Install Save as a script file and run: ## Quick Use ```bash pip install haystack-ai ``` ```python from haystack import Pipeline from haystack.components.generators import OpenAIGenerator from haystack.components.builders import PromptBuilder pipeline = Pipeline() pipeline.add_component("prompt", PromptBuilder(template="Answer: {{query}}")) pipeline.add_component("llm", OpenAIGenerator(model="gpt-4o")) pipeline.connect("prompt", "llm") result = pipeline.run({"prompt": {"query": "What is RAG?"}}) print(result["llm"]["replies"][0]) ``` --- ## Intro Haystack is a production-ready Python framework by deepset for building RAG pipelines, search systems, and AI agents with 20,000+ GitHub stars. Its composable pipeline architecture lets you connect retrievers, generators, rankers, and custom components like building blocks. Supports 30+ integrations including OpenAI, Anthropic, Pinecone, Weaviate, Elasticsearch, and more. Best for teams building production search and retrieval systems that need flexibility beyond simple API wrappers. Works with: Claude, GPT-4, Gemini, Cohere, local models via Ollama. Setup time: under 2 minutes. --- ## Core Concepts ### Composable Pipelines Build RAG, search, and agent pipelines by connecting components: ```python from haystack import Pipeline from haystack.components.retrievers import InMemoryBM25Retriever from haystack.components.generators import OpenAIGenerator from haystack.components.builders import PromptBuilder from haystack.document_stores.in_memory import InMemoryDocumentStore # Create a RAG pipeline store = InMemoryDocumentStore() pipeline = Pipeline() pipeline.add_component("retriever", InMemoryBM25Retriever(document_store=store)) pipeline.add_component("prompt", PromptBuilder( template="Context: {{documents}}\n\nQuestion: {{query}}\nAnswer:" )) pipeline.add_component("llm", OpenAIGenerator()) pipeline.connect("retriever", "prompt.documents") pipeline.connect("prompt", "llm") ``` ### Document Processing Ingest and process documents from any source: ```python from haystack.components.converters import PyPDFToDocument from haystack.components.preprocessors import DocumentCleaner, DocumentSplitter converter = PyPDFToDocument() cleaner = DocumentCleaner() splitter = DocumentSplitter(split_by="sentence", split_length=3) ``` ### Multiple Retrieval Strategies - BM25 (keyword search) - Dense retrieval (semantic search) - Hybrid (keyword + semantic) - Sparse retrieval ### 30+ Integrations | Category | Integrations | |----------|-------------| | LLMs | OpenAI, Anthropic, Cohere, Ollama | | Vector DBs | Pinecone, Weaviate, Qdrant, Chroma | | Search | Elasticsearch, OpenSearch | | Storage | S3, Azure Blob, Google Cloud | | Evaluation | RAGAS, DeepEval | ### Agent Capabilities ```python from haystack.components.agents import Agent agent = Agent( generator=OpenAIGenerator(), tools=[search_tool, calculator_tool, web_tool] ) result = agent.run("Research the latest AI trends and summarize") ``` ### Key Stats - 20,000+ GitHub stars - 30+ integrations - 500+ contributors - Production-ready since 2019 - Used by Fortune 500 companies ### FAQ **Q: What is Haystack?** A: Haystack is an open-source Python framework by deepset for building production RAG pipelines, search systems, and AI agents with composable, pluggable components. **Q: Is Haystack free?** A: Yes, fully open-source under Apache 2.0 license. deepset offers managed cloud hosting. **Q: How is Haystack different from LangChain?** A: Haystack focuses on production-grade pipelines with strong typing and component validation. LangChain is more flexible but less opinionated. Haystack excels at search and retrieval use cases. --- ## Source & Thanks > Created by [deepset](https://github.com/deepset-ai). Licensed under Apache 2.0. > > [haystack](https://github.com/deepset-ai/haystack) — ⭐ 20,000+ Thanks to the deepset team for making production RAG accessible to every developer. --- ## 快速使用 ```bash pip install haystack-ai ``` ```python from haystack import Pipeline from haystack.components.generators import OpenAIGenerator from haystack.components.builders import PromptBuilder pipeline = Pipeline() pipeline.add_component("prompt", PromptBuilder(template="回答: {{query}}")) pipeline.add_component("llm", OpenAIGenerator()) pipeline.connect("prompt", "llm") result = pipeline.run({"prompt": {"query": "什么是 RAG?"}}) ``` --- ## 简介 Haystack 是 deepset 团队开发的生产级 Python 框架,GitHub 20,000+ stars。用于构建 RAG 管道、搜索系统和 AI Agent,采用可组合的管道架构。支持 30+ 集成,包括 OpenAI、Anthropic、Pinecone、Elasticsearch 等。适合构建需要灵活性的生产搜索和检索系统。 --- ## 来源与感谢 > Created by [deepset](https://github.com/deepset-ai). Licensed under Apache 2.0. > > [haystack](https://github.com/deepset-ai/haystack) — ⭐ 20,000+ --- Source: https://tokrepo.com/en/workflows/1d2ed652-f347-4452-93f0-0b9a696466c2 Author: Script Depot