-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Is your feature request related to a problem? Please describe.
If an invalid / non-template value is provided as template in the ConditionalRouter, users get a somewhat cryptic:
RouteConditionException: Error evaluating condition for route '{'condition': '{{ flag == "double" }}', 'output': 2, 'output_name': 'num_additional_outputs', 'output_type': <class 'int'>}': Can't compile non template nodes
The above error happens for the setup below, where the user wants to output an int but has also specified the "output" template as an int 2 instead of a string such as "2" which would be a valid jinja template.
from haystack.components.routers import ConditionalRouter
routes = [
{
"condition": '{{ flag == "double" }}',
"output": 2,
"output_name": "num_additional_outputs",
"output_type": int
},
{
"condition": '{{ flag == "single" }}',
"output": 1,
"output_name": "num_additional_outputs",
"output_type": int
},
{
"condition": "{{ True }}",
"output": "None",
"output_name": "no_additional_outputs",
"output_type": str
}
]
router = ConditionalRouter(
routes=routes,
)
router.run(flag="double")Describe the solution you'd like
A more helpful error message could be nice. E.g. "The output template is not a string or a valid jinja template" or something along those lines.
Additional context
Add any other context or screenshots about the feature request here.