Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom components: Adding warning when not all inputs can be obtained #7371

Open
CharlesCousyn opened this issue Mar 15, 2024 · 0 comments
Open
Labels
2.x Related to Haystack v2.0

Comments

@CharlesCousyn
Copy link

Is your feature request related to a problem? Please describe.
Here a simplified RAG pipeline (where a directly inject documents for testing):
pipeline
The purpose of the latter is to offer a way of bypassing the generator when no documents is available using a ConditionalRouter.

The very last component of the pipeline is a custom component whose aim is to aggregate all variables in a payload that will be provided to build an API . Its code is as follows:

@component
class PayloadBuilder2:
    """
    A component to build the payload
    """

    @component.output_types(payload=Dict)
    def run(
            self,
            documents: List[Document],
            replies: List[ChatMessage],
            no_documents: str,
    ):
        print("PayloadBuilder.run")
        return {
            "payload": {
                "documents": documents,
                "no_documents": no_documents,
                "replies": replies,
            }
        }

The problem is that no matter what we send, the pipeline will return an empty dictionary:

{}

By debugging, i found that the the reason is that my custom component necessarily expects to have a value for no_documents input in order to be allowed to run.
The fix in my case was the following:
Replace:

   no_documents: str,

By

   no_documents: str="",

The default parameter allow the component to run even if the pipeline don't go through this no_documents branch!

Describe the solution you'd like
Could it be possible to get a warning/message at runtime or creation of the pipeline when a component that should be run cannot because it will never have its requested value? ( because of a CondionalRouter for example)

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@anakin87 anakin87 added type:feature New feature or request and removed type:feature New feature or request labels Mar 19, 2024
@shadeMe shadeMe added the 2.x Related to Haystack v2.0 label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0
Projects
None yet
Development

No branches or pull requests

4 participants