Skip to content

Commit

Permalink
Merge pull request #303 from XpressAI/wmeddie-none-checks
Browse files Browse the repository at this point in the history
Add IsNone and IsNotNone components
  • Loading branch information
MFA-X-AI authored Mar 7, 2024
2 parents 1bcebd6 + 40cc36f commit ef856da
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions xai_components/xai_controlflow/branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,24 @@ def __init__(self):
def execute(self, ctx) -> None:
ctx[self.name.value] = self.value.value
self.ref.set_fn(lambda: ctx[self.name.value])


@xai_component
class IsNone(Component):
a: InArg[any]

out: OutArg[bool]

def execute(self, ctx) -> None:
self.out.value = self.a.value is None


@xai_component
class IsNotNone(Component):
a: InArg[any]

out: OutArg[bool]

def execute(self, ctx) -> None:
self.out.value = self.a.value is not None

0 comments on commit ef856da

Please sign in to comment.