DeepsetStaticAnswerBuilder
Use this component to generate a fixed response every time you run it. You can configure the response text.
Basic Information
- Pipeline type: Query
- Type:
deepset_cloud_custom_nodes.augmenters.static_answer_builder.DeepsetStaticAnswerBuilder
- Components it can connect with:
- Any component that outputs a query string or accepts a list of generated answers as input.
Inputs
Required Inputs
Name | Type | Description |
---|---|---|
query | String | 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 . You can see an example in the Usage Examples section below. |
Optional Inputs
Name | Type | Default | Description |
---|---|---|---|
documents | List of Document objects | None | A list of documents. |
Outputs
Name | Type | Description |
---|---|---|
answers | List of GeneratedAnswer objects | Answers contain the answer text, the query, and documents if they were provided as input. |
Overview
DeepsetStaticAnswerBuilder is especially useful in pipelines that branch into multiple paths based on a condition. One of the paths then ends with DeepsetStatisAnswerBuilder to provide a default response when none of the other paths are taken.
You can also add metadata to the generated answer through the custom_meta_key
and custom_meta_value
parameters.
Usage Example
This is an example configuration 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
...
Init Parameters
Parameter | Type | Possible Values | Description |
---|---|---|---|
answer_text | String | The text of the generated answer this component outputs. Required. | |
custom_meta_key | String | Default: None | The key for a custom metadata field to be included in the answer. Optional. |
custom_meta_value | String | Default: None | The value for a custom metadata field to be included in the answer. Optional. |
Updated 2 months ago