Skip to content

Commit

Permalink
Added a new invoke_function: if_else (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
efunneko authored Aug 1, 2024
1 parent d40411a commit a8f72bf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/solace_ai_connector/common/invoke_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
empty_tuple = tuple
empty_float = lambda: 0.0
empty_int = lambda: 0
if_else = lambda x, y, z: y if x else z


# A few test functions
Expand Down
20 changes: 20 additions & 0 deletions tests/test_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,24 @@
},
},
},
"if_else_true": {
"invoke": {
"module": "invoke_functions",
"function": "if_else",
"params": {
"positional": [True, 1, 2],
},
},
},
"if_else_false": {
"invoke": {
"module": "invoke_functions",
"function": "if_else",
"params": {
"positional": [False, 1, 2],
},
},
},
},
},
"expected": {
Expand All @@ -325,6 +343,8 @@
"not_op": False,
"in_op": True,
"negate": -1,
"if_else_true": 1,
"if_else_false": 2,
},
},
},
Expand Down

0 comments on commit a8f72bf

Please sign in to comment.