Closed AK391 closed 2 years ago
One way to do this would be to allow optional outputs ONLY AFTER the required outputs. Depending on how many values the function returns, the interface would or would not render the optional outputs.
@abidlabs @dawoodkhan82 what are your latest thoughts and status on this issue? I am finalizing #430 right now and this felt related.
Was talking to @aliabid94 when I learned that we already support this! You can just return None
for any of the return values and the output component will not be rendered!
I'm going to leave this issue open as a reminder we should document this behavior somewhere. Maybe writing a mini guide on optional input and output components?
@abidlabs The behavior you talk about (returning None makes the component invisible) is actually not what happens now.
I think the better way of supporting "optional" rendering is via gr.update
and that's already covered in the docs and guides. If anything we can add a code snippet to the forthcoming recipe/playground page (#1860). But I think we should close.
Ah that's interesting... agreed we'll document gr.update()
as part of #1359, so I don't think we need it here.
Is your feature request related to a problem? Please describe. Discussed with @abidlabs to add optional output components for use cases such as https://huggingface.co/spaces/docs-demos/bart-large-mnli where multiple tasks are in one space (zero shot classification, summarization) based on the model/checkpoint selected