-
Notifications
You must be signed in to change notification settings - Fork 44.5k
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
feat(platform) : single input validation lock #8856
Open
Abhi1992002
wants to merge
3
commits into
Significant-Gravitas:dev
Choose a base branch
from
Abhi1992002:feat/single-input-validation-lock
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+149
−15
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
autogpt_platform/backend/backend/blocks/test_mutual_exclusive.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from typing import Optional | ||
|
||
from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema | ||
from backend.data.model import SchemaField | ||
|
||
|
||
class TestMutualExclusiveBlock(Block): | ||
class Input(BlockSchema): | ||
text_input_1: Optional[str] = SchemaField( | ||
title="Text Input 1", | ||
description="First mutually exclusive input", | ||
mutually_exclusive="group_1", | ||
) | ||
|
||
text_input_2: Optional[str] = SchemaField( | ||
title="Text Input 2", | ||
description="Second mutually exclusive input", | ||
mutually_exclusive="group_1", | ||
) | ||
|
||
text_input_3: Optional[str] = SchemaField( | ||
title="Text Input 3", | ||
description="Third mutually exclusive input", | ||
mutually_exclusive="group_1", | ||
) | ||
|
||
number_input_1: Optional[int] = SchemaField( | ||
title="Number Input 1", | ||
description="First number input (mutually exclusive)", | ||
mutually_exclusive="group2", | ||
) | ||
|
||
number_input_2: Optional[int] = SchemaField( | ||
title="Number Input 2", | ||
description="Second number input (mutually exclusive)", | ||
mutually_exclusive="group2", | ||
) | ||
|
||
independent_input: str = SchemaField( | ||
title="Independent Input", | ||
description="This input is not mutually exclusive with others", | ||
default="This can be filled anytime", | ||
) | ||
|
||
class Output(BlockSchema): | ||
result: str = SchemaField(description="Shows which inputs were filled") | ||
|
||
def __init__(self): | ||
super().__init__( | ||
id="b7faa910-b074-11ef-bee7-477f51db4711", | ||
description="A test block to demonstrate mutually exclusive inputs", | ||
categories={BlockCategory.BASIC}, | ||
input_schema=TestMutualExclusiveBlock.Input, | ||
output_schema=TestMutualExclusiveBlock.Output, | ||
) | ||
|
||
def run(self, input_data: Input, **kwargs) -> BlockOutput: | ||
filled_inputs = [] | ||
|
||
if input_data.text_input_1: | ||
filled_inputs.append(f"Text Input 1: {input_data.text_input_1}") | ||
if input_data.text_input_2: | ||
filled_inputs.append(f"Text Input 2: {input_data.text_input_2}") | ||
if input_data.text_input_3: | ||
filled_inputs.append(f"Text Input 3: {input_data.text_input_3}") | ||
|
||
if input_data.number_input_1: | ||
filled_inputs.append(f"Number Input 1: {input_data.number_input_1}") | ||
if input_data.number_input_2: | ||
filled_inputs.append(f"Number Input 2: {input_data.number_input_2}") | ||
|
||
filled_inputs.append(f"Independent Input: {input_data.independent_input}") | ||
|
||
yield "result", "\n".join(filled_inputs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is a good addition - for the tests however, I wonder if you could put the tests in one of the real blocks to show it working?