Haystack Experimental Components
haystack-experimental provides experimental components and features for the Haystack LLM framework (version 2.x). It offers early access to new ideas, integrations, and architectural patterns before they potentially graduate to the main Haystack library. Currently at version 0.19.0, it has a frequent release cadence, often aligning with or preceding Haystack core releases, reflecting its rapidly evolving nature.
Warnings
- breaking Components within `haystack-experimental` are volatile. Their APIs are unstable and subject to frequent breaking changes, renaming, or complete removal without prior notice due to their experimental nature.
- gotcha Compatibility with the core `haystack-ai` library is tightly coupled. Updates to either `haystack-experimental` or `haystack-ai` can introduce incompatibilities, requiring specific version alignments.
- breaking Python 3.9 support was dropped, requiring Python 3.10 or newer.
- deprecated The `EmbedderBasedDocumentsplitter` component was removed.
- deprecated Human-in-the-Loop (HiTL) related code was removed as it migrated out of `haystack-experimental`.
Install
-
pip install "haystack-experimental[openai]" -
pip install haystack-experimental
Imports
- Agent
from haystack_experimental.agents.agent import Agent
- InMemoryChatMessageStore
from haystack_experimental.memory.in_memory_chat_message_store import InMemoryChatMessageStore
- MarkdownHeaderLevelInferrer
from haystack_experimental.preprocessors.markdown_header_level_inferrer import MarkdownHeaderLevelInferrer
Quickstart
import os
from haystack_experimental.agents.agent import Agent
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.components.builders.prompt_builder import PromptBuilder
# Ensure your OpenAI API key is set as an environment variable
os.environ['OPENAI_API_KEY'] = os.environ.get('OPENAI_API_KEY', 'sk-...')
# Initialize LLM and PromptBuilder
llm = OpenAIChatGenerator()
prompt_builder = PromptBuilder(template="{{ query }}")
# Create an experimental Agent
agent = Agent(
tools=[], # Agents can use tools, but for this quickstart we'll keep it simple
prompt_builder=prompt_builder,
llm=llm,
max_iterations=3,
debug=True
)
# Run the agent
result = agent.run(query="What is the capital of France?")
print(f"Agent Output: {result.answer}")