AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
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 🌈
Let's understand the problem with an example
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:
If one input depends upon another input and you fill only one, then you can't run the block; you get a frontend error.
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:
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.
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.
Duplicates
Summary 💡
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 🌈
Let's understand the problem with an example
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 asmedia_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:
If one input depends upon another input and you fill only one, then you can't run the block; you get a frontend error.
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:
depends
field in the input.If you haven't written anything in
poll_options
, thenpoll_duration_minutes
is disabled.network
similar toDocker.
If 3 inputs are on the same network, then you can only select one.If multiple inputs are on the same network, then you can only fill one.
Motivation 🔦
No response