deepset-ai / haystack

:mag: AI orchestration framework to build customizable, production-ready LLM applications. Connect components (models, vector DBs, file converters) to pipelines or agents that can interact with your data. With advanced retrieval methods, it's best suited for building RAG, question answering, semantic search or conversational agent chatbots.
https://haystack.deepset.ai
Apache License 2.0
16.94k stars 1.85k forks source link

feat: Add `unsafe` init arg in `ConditionalRouter` and `OutputAdapter` to enable previous behaviour #8176

Closed silvanocerza closed 3 weeks ago

silvanocerza commented 1 month ago

Related Issues

Proposed Changes:

After some discussion we decided to add back the unsafe behaviour in ConditionalRouter and OutputAdapter that was removed with #8095.

This PR adds an unsafe init argument for both Component that will enable the previous behaviour. unsafe defaults to False, so the user must explictly set it to True to use the previous behaviour.

We recommend not enabling unsafe behaviour if the Jinja template sources are not trusted.

PromptBuilder, ChatPromptBuilder, DynamicPromptBuilder and DynamicChatPromptBuilder were also changed in the previous PR but it doesn't make sense to enable the unsafe behaviour for those Component so we leave them as is.

How did you test it?

I added new tests and run tests locally.

Notes for the reviewer

We'll need to update the ConditionalRouter and OutputAdapter documentation to make the unsafe behaviour clear and to explain when it must not be enabled.

Checklist

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 10668494516

Details


Files with Coverage Reduction New Missed Lines %
components/converters/output_adapter.py 1 98.48%
components/routers/conditional_router.py 2 97.73%
<!-- Total: 3 -->
Totals Coverage Status
Change from base Build 10664748045: 0.02%
Covered Lines: 7015
Relevant Lines: 7776

đŸ’› - Coveralls