Skip to content

Commit

Permalink
update strings, reload workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
MFA-X-AI committed Jul 22, 2024
1 parent a6e2ba9 commit ddc25df
Show file tree
Hide file tree
Showing 10 changed files with 1,058 additions and 1,004 deletions.
356 changes: 178 additions & 178 deletions xai_components/xai_controlflow/ControlflowBranch.xircuits

Large diffs are not rendered by default.

366 changes: 183 additions & 183 deletions xai_components/xai_controlflow/ControlflowCounterLoop.xircuits

Large diffs are not rendered by default.

210 changes: 105 additions & 105 deletions xai_components/xai_controlflow/ControlflowLoop.xircuits

Large diffs are not rendered by default.

103 changes: 92 additions & 11 deletions xai_components/xai_controlflow/branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

@xai_component(type='branch')
class BranchComponent(Component):
"""A component that conditionally executes one of two branches based on a boolean condition.
##### inPorts:
- condition (bool): A boolean condition to evaluate.
##### Branches:
- when_true: Branch that executes if the condition is True.
- when_false: Branch that executes if the condition is False.
"""
when_true: BaseComponent
when_false: BaseComponent

Expand All @@ -22,8 +31,15 @@ def do(self, ctx) -> BaseComponent:

@xai_component(type='branch')
class LoopComponent(Component):
"""A component that loops while the condition is True.
##### inPorts:
- condition (bool): Boolean that determines whether `body` branch is executed.
##### Branches:
- body: Branch that executes in each iteration of the loop.
"""
body: BaseComponent

condition: InArg[bool]

def do(self, ctx) -> BaseComponent:
Expand All @@ -37,10 +53,20 @@ def do(self, ctx) -> BaseComponent:

@xai_component(type='branch')
class ReverseForEach(Component):
body: BaseComponent
"""A component that iterates over a list in reverse order, executing body branches for each item.
##### inPorts:
- items (list): The list of items to iterate over.
##### outPorts:
- current_item (any): The current item in the iteration.
- current_index (int): The index of the current item in the iteration.
##### Branches:
- body: Branch that executes for each item.
"""
body: BaseComponent
items: InCompArg[list]

current_item: OutArg[any]
current_index: OutArg[int]

Expand All @@ -55,13 +81,22 @@ def do(self, ctx) -> BaseComponent:
if hasattr(self, 'next') and self.next:
return self.next


@xai_component(type='branch')
class ForEach(Component):
body: BaseComponent
"""A component that iterates over a list, executing body branches for each item.
##### inPorts:
- items (list): The list of items to iterate over.
##### outPorts:
- current_item (any): The current item in the iteration.
- current_index (int): The index of the current item in the iteration.
##### Branches:
- body: Branch that executes for each item.
"""
body: BaseComponent
items: InCompArg[list]

current_item: OutArg[any]
current_index: OutArg[int]

Expand All @@ -78,10 +113,18 @@ def do(self, ctx) -> BaseComponent:

@xai_component
class CounterComponent(Component):
"""A component that maintains and increments a counter.
##### inPorts:
- start_number (int): The initial value of the counter.
- step (int): The increment step for the counter.
##### outPorts:
- out_number (int): The current value of the counter.
"""
start_number: InArg[int]
step: InArg[int]
out_number: OutArg[int]

state: any

def __init__(self):
Expand All @@ -98,10 +141,19 @@ def execute(self, ctx) -> None:

@xai_component
class ComparisonComponent(Component):
"""A component that performs a comparison between two integers.
##### inPorts:
- a (int): The first integer.
- b (int): The second integer.
- op (str): The comparison operator (as a string).
##### outPorts:
- out (bool): The result of the comparison (boolean).
"""
a: InArg[int]
b: InArg[int]
op: InArg[str]

out: OutArg[bool]

def execute(self, ctx) -> None:
Expand All @@ -124,6 +176,14 @@ def value(self) -> any:

@xai_component(type='context_get')
class GetVariableComponent(Component):
"""A component that retrieves a variable from the context.
##### inPorts:
- name (str): The name of the variable to retrieve.
##### outPorts:
- value (any): The value of the retrieved variable.
"""
name: InArg[str]
value: OutArg[any]

Expand All @@ -137,6 +197,12 @@ def execute(self, ctx) -> None:

@xai_component(type='context_set')
class SetVariableComponent(Component):
"""A component that sets a variable in the context.
##### inPorts:
- name (str): The name of the variable to set.
- value (any): The value to set for the variable.
"""
name: InArg[str]
value: InArg[any]

Expand All @@ -146,11 +212,19 @@ def execute(self, ctx) -> None:

@xai_component(type='variable')
class DefineVariableComponent(Component):
"""A component that defines a variable in the context and creates a reference to it.
##### inPorts:
- name (str): The name of the variable to define.
- value (any): The initial value of the variable.
##### outPorts:
- ref (any): A reference to the defined variable.
"""
name: InArg[str]
value: InArg[any]
ref: OutArg[any]


def __init__(self):
super().__init__()
self.ref = MutableVariable()
Expand All @@ -162,10 +236,17 @@ def execute(self, ctx) -> None:

@xai_component
class EvalBooleanExpression(Component):
"""A component that evaluates a boolean expression.
##### inPorts:
- expression (str): The boolean expression to evaluate.
- args (dynalist): A list of arguments to use in the expression.
##### outPorts:
- out (bool): The result of the evaluated expression (boolean).
"""
expression: InCompArg[str]

args: InArg[dynalist]

out: OutArg[bool]

def execute(self, ctx) -> None:
Expand Down
Loading

0 comments on commit ddc25df

Please sign in to comment.