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 reset to entrypoint to app

elijahbenizzy8668bfc01248
diff --git a/burr/core/application.py b/burr/core/application.py
index 7382dd80..87146a77 100644
--- a/burr/core/application.py
+++ b/burr/core/application.py
@@ -375,6 +375,10 @@ class Application:
)
return next_action, result, new_state
+ def reset_to_entrypoint(self) -> None:
+ """Resets the state machine to the entrypoint action."""
+ self._set_state(self._state.wipe(delete=[PRIOR_STEP]))
+
def _update_internal_state_value(self, new_state: State, next_action: Action) -> State:
"""Updates the internal state values of the new state."""
new_state = new_state.update(
@@ -1396,11 +1400,14 @@ class ApplicationBuilder:
else:
# else we failed we just start at that node
self.start = last_position
- self.state = self.state.wipe(delete=[PRIOR_STEP])
+ self.reset_to_entrypoint()
else:
# self.start is already set to the default. We don't need to do anything.
pass
+ def reset_to_entrypoint(self):
+ self.state = self.state.wipe(delete=[PRIOR_STEP])
+
@telemetry.capture_function_usage
def build(self) -> Application:
"""Builds the application.