-
Notifications
You must be signed in to change notification settings - Fork 20
feat: add custom guardrails implementation [AL-197] #920
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
base: main
Are you sure you want to change the base?
Conversation
7f02b34 to
e8ce7af
Compare
dbdf973 to
fbf9514
Compare
fe4e4c7 to
89ce1b7
Compare
| IS_NOT_EMPTY = "isNotEmpty" | ||
| MATCHES_REGEX = "matchesRegex" | ||
| STARTS_WITH = "startsWith" | ||
| FUNC = "func" |
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.
Do we really need this operator type? I agree with the function for evaluation, but I challenge the FUNC operator type.
| except Exception: | ||
| # If function raises an exception, treat as failure | ||
| passed = False | ||
| elif rule.operator == NumberOperator.EQUALS: |
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.
I propose we only keep the func evaluation. It is more flexible and we can easily convert all the statis operators into funcs during the conversion (when we create the guardrails from their definitions).
I think we can even have one single function like:
def evaluate_rule( rule_func, input_data, output_data ) -> tuple[bool, str | None]
| return True, "All number rule validations passed" | ||
|
|
||
|
|
||
| def evaluate_boolean_rule( |
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.
Does it work to have a single function to evaluate word|number|boolean rules?
| ) | ||
|
|
||
| @traced("evaluate_pre_custom_guardrails", run_type="uipath") | ||
| def evaluate_pre_custom_guardrails( |
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.
Use singular -> evaluate_pre_custom_guardrail. Same for the below functions too.
|
|
||
| DOES_NOT_EQUAL = "doesNotEqual" | ||
| EQUALS = "equals" | ||
| FUNC = "func" |
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.
do we still need this?
| Field(discriminator="rule_type"), | ||
| ] | ||
|
|
||
| AgentRule = Annotated[ |
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.
All types prefixed by Agent should stay in agent.py file.
| model_config = ConfigDict(populate_by_name=True, extra="allow") | ||
|
|
||
|
|
||
| class LowCodeCustomGuardrail(BaseGuardrail): |
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.
We already have a AgentCustomGuardrails model. Why not updating that one with the new types?
| "Guardrail", | ||
| "BuiltInValidatorGuardrail", | ||
| "CustomGuardrail", | ||
| "LowCodeCustomGuardrail", |
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.
We shouldn't expose these here. They are agent related.
No description provided.