Skip to content

armgit / burr

Public Imported from GitHub
0

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.

Adds docs for update() function to Reducer

elijahbenizzy1cde57e0601c
diff --git a/burr/core/action.py b/burr/core/action.py
index 47cc9457..e3f17082 100644
--- a/burr/core/action.py
+++ b/burr/core/action.py
@@ -142,6 +142,19 @@ class Reducer(abc.ABC):
@abc.abstractmethod
def update(self, result: dict, state: State) -> State:
+ """Performs a state update given a result and the current state.
+ Returns a new, modified :py:class:`State <burr.core.state.State>`
+ (recall state is immutable -- simply changing the state in place will not work).
+
+ In the context of Burr, this is only applied in the two-step actions, where
+ the :py:meth:`run <burr.core.action.Function.run>` and update() functions are separate. The
+ function-based APIs for Burr use the SingleStepAction class, which performs them both at once.
+ This is not (yet) exposed as an interface for users to extend.
+
+ :param result: Result of a function executing on the state
+ :param state: State to update
+ :return: A new, modified state.
+ """
pass