feat: add custom jinja filter handling to ConditionalRouter
Related Issues
- fixes #7940
Proposed Changes:
Added a custom_filters: Optional[Dict[str, Callable]] field to the ConditionalRouter constructor to allow users to pass in and use custom Jinja2 filters when creating route conditions. Also added the same field to from_dict to allow users to provide callables when de-serializing a ConditionalRouter that was serialized with custom filters.
How did you test it?
Added 3 unit tests to test/components/routers/test_conditional_router.py:
-
test_custom_filter- ensures a custom test filter works with the router -
test_custom_filter_serialization- ensures the router with the custom filter attribute can be serialized and de-serialized -
test_custom_filter_bad_deserialization- ensures that a custom exception is generated when a router with custom filers is deserialized without providing callables
Notes for the reviewer
I updated the docstring with usage information, but not sure what your documentation requirements are otherwise.
Checklist
- I have read the contributors guidelines and the code of conduct
- I have updated the related issue with new insights and changes
- I added unit tests and updated the docstrings
- I've used one of the conventional commit types for my PR title:
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:. - I documented my code
- I ran pre-commit hooks and fixed any issue
Pull Request Test Coverage Report for Build 9718882629
Details
- 0 of 0 changed or added relevant lines in 0 files are covered.
- 2 unchanged lines in 1 file lost coverage.
- Overall coverage increased (+0.01%) to 89.989%
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| components/routers/conditional_router.py | 2 | 97.5% |
| <!-- | Total: | 2 |
| Totals | |
|---|---|
| Change from base Build 9710252897: | 0.01% |
| Covered Lines: | 6751 |
| Relevant Lines: | 7502 |
💛 - Coveralls
Pull Request Test Coverage Report for Build 9724715471
Details
- 0 of 0 changed or added relevant lines in 0 files are covered.
- 2 unchanged lines in 1 file lost coverage.
- Overall coverage increased (+0.01%) to 89.989%
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| components/routers/conditional_router.py | 2 | 97.5% |
| <!-- | Total: | 2 |
| Totals | |
|---|---|
| Change from base Build 9710252897: | 0.01% |
| Covered Lines: | 6751 |
| Relevant Lines: | 7502 |
💛 - Coveralls
Not sure what to do about these integration test errors (all seem related to OpenAI):
Indeed unrelated, thanks @ChrisPappalardo we'll take a look at integrating this one soon 🙏
@shadeMe it would be nice to include this one in the upcoming release, if possible 😄
Pull Request Test Coverage Report for Build 9740569615
Details
- 0 of 0 changed or added relevant lines in 0 files are covered.
- 2 unchanged lines in 1 file lost coverage.
- Overall coverage increased (+0.01%) to 89.989%
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| components/routers/conditional_router.py | 2 | 97.5% |
| <!-- | Total: | 2 |
| Totals | |
|---|---|
| Change from base Build 9740565126: | 0.01% |
| Covered Lines: | 6751 |
| Relevant Lines: | 7502 |
💛 - Coveralls
Pull Request Test Coverage Report for Build 9768491597
Details
- 0 of 0 changed or added relevant lines in 0 files are covered.
- 2 unchanged lines in 1 file lost coverage.
- Overall coverage increased (+0.008%) to 89.976%
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| components/routers/conditional_router.py | 2 | 97.4% |
| <!-- | Total: | 2 |
| Totals | |
|---|---|
| Change from base Build 9758508178: | 0.008% |
| Covered Lines: | 6750 |
| Relevant Lines: | 7502 |
💛 - Coveralls
Pull Request Test Coverage Report for Build 9779774624
Warning: This coverage report may be inaccurate.
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
- For more information on this, see Tracking coverage changes with pull request builds.
- To avoid this issue with future PRs, see these Recommended CI Configurations.
- For a quick fix, rebase this PR at GitHub. Your next report should be accurate.
Details
- 0 of 0 changed or added relevant lines in 0 files are covered.
- 2 unchanged lines in 1 file lost coverage.
- Overall coverage increased (+0.03%) to 89.997%
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| components/routers/conditional_router.py | 2 | 97.4% |
| <!-- | Total: | 2 |
| Totals | |
|---|---|
| Change from base Build 9758508178: | 0.03% |
| Covered Lines: | 6766 |
| Relevant Lines: | 7518 |
💛 - Coveralls
Pull Request Test Coverage Report for Build 9782596228
Details
- 0 of 0 changed or added relevant lines in 0 files are covered.
- 2 unchanged lines in 1 file lost coverage.
- Overall coverage increased (+0.008%) to 89.997%
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| components/routers/conditional_router.py | 2 | 97.4% |
| <!-- | Total: | 2 |
| Totals | |
|---|---|
| Change from base Build 9777342637: | 0.008% |
| Covered Lines: | 6766 |
| Relevant Lines: | 7518 |
💛 - Coveralls
Thanks for this amazing contribution @ChrisPappalardo Keep them coming!
Happy to contribute, I'm a fan of this project!