DocumentationAPI Reference📓 Tutorials🧑‍🍳 Cookbook🤝 Integrations💜 Discord🎨 Studio (Waitlist)
Documentation

Debugging Pipelines

Learn how to debug and troubleshoot your Haystack pipelines.

Inspecting Component Outputs

To see the outputs of specific components in your pipeline, include the include_outputs_from parameter during execution. Set this parameter to the component names whose outputs you want included in the pipeline's result.

For example, here’s how you can print the output of PromptBuilder in this pipeline:

from haystack import Pipeline, Document
from haystack.utils import Secret
from haystack.components.generators import OpenAIGenerator
from haystack.components.builders.prompt_builder import PromptBuilder

documents = [Document(content="Joe lives in Berlin"), Document(content="Joe is a software engineer")]
prompt_template = """
    Given these documents, answer the question.\\nDocuments:
    {% for doc in documents %}
        {{ doc.content }}
    {% endfor %}

    \\nQuestion: {{query}}
    \\nAnswer:
    """

p = Pipeline()
p.add_component(instance=PromptBuilder(template=prompt_template), name="prompt_builder")
p.add_component(instance=OpenAIGenerator(api_key=Secret.from_env_var("OPENAI_API_KEY")), name="llm")
p.connect("prompt_builder", "llm")

question = "Where does Joe live?"

# We are adding `include_outputs_from` here to view the prompt template created by PromptBuilder
result = p.run({"prompt_builder": {"documents": documents, "query": question}},
               include_outputs_from={"prompt_builder"})

print(result)

Tracing

Alternatively, to get a bigger picture of the pipeline’s performance, try tracing it with Langfuse.