Debugging Pipelines
Learn how to debug and troubleshoot your Haystack pipelines.
There are several options available to you to debug your pipelines:
- Inspect your components' outputs
- Adjust logging
- Set up tracing
- Try one of the monitoring tool integrations
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 to be 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)
Logging
Adjust the logging format according to your debugging needs. See our Logging documentation for details.
Tracing
To get a bigger picture of the pipeline’s performance, try tracing it with Langfuse.
Our Tracing page has more about other tracing solutions for Haystack.
Monitoring Tools
Take a look at available tracing and monitoring integrations for Haystack pipelines, such as Arize AI or Arize Phoenix.
Updated 2 months ago