DeepsetStaticAnswerBuilder
Generate a fixed response text every time it runs. Use it to provide fallback or default answers in conditional pipelines.
Key Features
- Returns a fixed, pre-configured answer text for every pipeline run.
- Useful for fallback paths in branching pipelines, such as returning a default message when a query is rejected or a condition is not met.
- Optionally attaches documents to the generated answer.
- Supports adding custom metadata to the answer using a configurable key-value pair.
Configuration
- Drag the
DeepsetStaticAnswerBuildercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Enter the
answer_text— the fixed response text to return.
- Enter the
- Go to the Advanced tab to configure additional settings:
- Optionally set
custom_meta_keyandcustom_meta_valueto add custom metadata to the generated answer.
- Optionally set
Connections
DeepsetStaticAnswerBuilder receives a query string as input. If it doesn't receive the query from a connected component, list it in the inputs section of the pipeline YAML. Optionally, it also accepts documents to include in the answer.
Connect its answers output to the pipeline Output component to surface the fixed response.
Usage Examples
Basic Configuration
DeepsetStaticAnswerBuilder:
type: deepset_cloud_custom_nodes.augmenters.static_answer_builder.DeepsetStaticAnswerBuilder
init_parameters: {}
Using the Component in the Pipeline
This is an example pipeline where the Router classifies queries into injections and legitimate queries. It sends the injections to DeepsetStaticAnswerBuilder, which returns "Cannot answer", while the legitimate queries go to OutputAdapter.
components:
# ...
router:
type: haystack.components.routers.transformers_text_router.TransformersTextRouter
init_parameters:
model: "JasperLS/deberta-v3-base-injection"
labels: ["LEGIT", "INJECTION"]
answer_builder:
type: deepset_cloud_custom_nodes.augmenters.static_answer_builder.DeepsetStaticAnswerBuilder
init_parameters:
answer_text: "Cannot answer"
custom_meta_key: "error_code"
custom_meta_value: "403"
output_adapter:
type: haystack.components.converters.OutputAdapter
init_parameters:
output_type: str
template: >
"Good question: {{query}}"
connections: # Defines how the components are connected
# ...
- sender: router.INJECTION
receiver: answer_builder.query
- sender: router.LEGIT
receiver: output_adapter.query
Parameters
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
query | str | The query string. If DeepsetStaticAnswerBuilder doesn't receive the query from a component it's connected to, you must list it in the inputs section of the pipeline YAML under query. | |
documents | Optional[List[Document]] | None | Documents to add to the answer. |
Outputs
| Parameter | Type | Description |
|---|---|---|
answers | List[GeneratedAnswer] | A list of GeneratedAnswer objects. Each answer contains the answer text, the query, the documents (if provided), and custom metadata. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
answer_text | str | The text of the GeneratedAnswer this component outputs. | |
custom_meta_key | Optional[str] | None | The key for a custom metadata field to be included in the answer. |
custom_meta_value | Optional[str] | None | The value for a custom metadata field to be included in the answer. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
query | str | The query string. If DeepsetStaticAnswerBuilder doesn't receive the query from a component it's connected to, you must list it in the inputs section of the pipeline YAML under query. | |
documents | Optional[List[Document]] | None | Documents to add to the answer. |
Was this page helpful?