Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.
Python aiburrchatbot-frameworkdagsgenerative-aigraphshacktoberfestllmopsllmsmlopspersistent-data-structurestate-machinestate-managementvisibility
Removes unused validation function
elijahbenizzy8c402b834b6a
diff --git a/burr/core/action.py b/burr/core/action.pyindex b753e24a..60aa979f 100644--- a/burr/core/action.py+++ b/burr/core/action.py@@ -1000,41 +1000,6 @@ class FunctionBasedStreamingAction(SingleStepStreamingAction):return inspect.getsource(self._fn)-def _validate_action_function(fn: Callable):- """Validates that an action has the signature: (state: State) -> tuple[dict, State]-- :param fn: Function to validate- """- sig = inspect.signature(fn)- params = sig.parameters- if list(params.keys())[0] != "state" or not list(params.values())[0].annotation == State:- raise ValueError(f"Function {fn} must take in a single argument: state with type: State")- other_params = list(params.keys())[1:]- for param in other_params:- param = params[param]- if param.kind not in {- inspect.Parameter.POSITIONAL_OR_KEYWORD,- inspect.Parameter.KEYWORD_ONLY,- }:- raise ValueError(- f"Function {fn} has an invalid parameter: {param}. "- f"All parameters must be position or keyword only,"- f"so that bind(**kwargs) can be applied."- )-- return_type = sig.return_annotation- if (- return_type is inspect.Signature.empty- or not typing.get_origin(return_type) in {tuple, typing.Tuple}- or not len(typing.get_args(return_type)) == 2- or not typing.get_args(return_type) == (dict, State)- ):- raise ValueError(- f"Function {fn} must return a tuple of (result, new_state), with type tuple[dict, State] "- f"not {sig.return_annotation}"- )--C = TypeVar("C", bound=Callable) # placeholder for any Callablediff --git a/tests/core/test_action.py b/tests/core/test_action.pyindex fd141844..499f98d0 100644--- a/tests/core/test_action.py+++ b/tests/core/test_action.py@@ -16,7 +16,6 @@ from burr.core.action import (SingleStepStreamingAction,StreamingAction,StreamingResultContainer,- _validate_action_function,action,create_action,default,@@ -449,36 +448,6 @@ def test_create_action_undecorated_function():create_action(test_action, name="my_action")-def test__validate_action_function_invalid_signature_extra_parameters():- def incorrect_signature(state: State, extra_to_bind: str) -> Tuple[dict, State]:- pass-- _validate_action_function(incorrect_signature)---def test__validate_action_function_invalid_signature_incorrect_param_type():- def incorrect_signature(state: int) -> Tuple[dict, State]:- pass-- with pytest.raises(ValueError, match="single argument"):- _validate_action_function(incorrect_signature)---def test__validate_action_function_invalid_signature_incorrect_return_type():- def incorrect_signature(state: State) -> int:- pass-- with pytest.raises(ValueError, match="must return"):- _validate_action_function(incorrect_signature)---def test__validate_action_function_invalid_signature_correct():- def correct_signature(state: State) -> Tuple[dict, State]:- pass-- _validate_action_function(correct_signature)--def test_streaming_action_stream_run():class SimpleStreamingAction(StreamingAction):def stream_run(