Skip to content

Add warning to PromptBuilder and ChatPromptBuilder if no required_variables is set #8901

@sjrl

Description

@sjrl

Is your feature request related to a problem? Please describe.
Most of our components require some (or all) inputs during runtime. For our components whose inputs are based on Jinja2 templates (e.g. ConditionalRouter, OutputAdpater, PromptBuilder, and ChatPromptBuilder) we differ on how we treat whether all Jinja2 variables are required or are optional by default. For example, the components ConditionalRouter, and OutputAdpater we require all Jinja2 variables defined in their templates to run. But for the PromptBuilder, and ChatPromptBuilder we set all Jinja2 variables as optional by default.

This optionality has caused "intended" but usually unexpected behavior (from the perspective of the user) when running pipelines with multiple branches where each branch may contain a (Chat)PromptBuilder + (Chat)Generator. Specifically, if no required variables are set in the prompt builder then that component will always trigger even if it's along a branch that has been turned "off" by a previous ConditionalRouter.

Describe the solution you'd like
To help make users aware of this behavior @julian-risch and I agreed that adding a warning to the init method of the PromptBuilder and ChatPromptBuilder when 1) Jinja2 variables are present in the template and 2) required_variables=None makes sense.

This way users can be better aware that these components can still trigger even if they receive no input.

Additional context
@ju-gu and I have run into this multiple times when building pipelines for clients.

Metadata

Metadata

Assignees

Labels

P1High priority, add to the next sprint

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions