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

Add Input Dependencies and Exclusive Options to Prevent Conflicting Inputs #8731

Open
Abhi1992002 opened this issue Nov 20, 2024 · 1 comment

Comments

@Abhi1992002
Copy link
Contributor

Abhi1992002 commented Nov 20, 2024

We need to implement functionality on both the frontend and backend to handle input dependencies and mutual exclusivity in blocks. This includes disabling dependent inputs when prerequisites are not met and ensuring only one input from a group of mutually exclusive options can be selected.

Examples

Suppose we have a block that helps you to create a tweet.

Possible inputs in this could be:

-text

-media_ids

-place_ids

-quote_ids

-dm_deep_link

-poll_options

-poll_minutes (must be used with poll_options)

With text, we could only provide one option from the above inputs. If the user provides more than one option, they might get an error. Suppose they have given poll_options as well as media_ids; they get a 400 bad request.

Now, what do you need to do?

You need to add functionality on both frontend and backend so that:

  1. If one input depends upon another input and you fill only one, then you can't run the block; you get a frontend error.

  2. You are able to make a way so that if you have 5 inputs and you need to fill only one, once you fill it, all the other inputs are disabled. Or if some user tries to send data (I know he can't after disabled but as an extra security layer), if he sends it then he gets a frontend error.

My tips that you can consider:

  1. We could add a depends field in the input.
poll_options: list = SchemaField(
    description="List of poll options",
    placeholder="Enter poll options",
)

poll_duration_minutes: int = SchemaField(
    description="Duration of the poll in minutes",
    default=1440,  # 24 hours
    depends=[poll_options],
    required=False,
)

If you haven't written anything in poll_options, then poll_duration_minutes is disabled.

  1. You could give a field network similar to Docker. If 3 inputs are on the same network, then you can only select one.
place_id: str | None = SchemaField(
    description="Adds optional location information to a tweet if geo settings are enabled in your profile.",
    default=None,
    required=False,
    network='dumbledore'
)

quote_tweet_id: str | None = SchemaField(
    description="Link to the Tweet being quoted",
    default=None,
    placeholder="e.g., 1455953449422516226",
    required=False,
    network='dumbledore'
)

direct_message_deep_link: str | None = SchemaField(
    description="Link directly to a Direct Message conversation with an account",
    default=None,
    placeholder="e.g., https://twitter.com/messages/compose?recipient_id={your_id}",
    required=False,
    network='dumbledore'
)

If multiple inputs are on the same network, then you can only fill one.

Note: The above two are only suggestions that came in my mind instantly; they might have some possible errors or drawbacks or there might be a better way to do it, so take them as suggestions, not the answer.

@ntindle
Copy link
Member

ntindle commented Nov 27, 2024

Have you taken a look at the llm block for how it handles providers? Also I think this may tie in well with dynamic outputs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants