DAGWorks-Inc / burr

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.
https://burr.dagworks.io
BSD 3-Clause Clear License
1.12k stars 59 forks source link

typing: `Application.step()` #353

Open zilto opened 1 week ago

zilto commented 1 week ago

Currently, Application.step() gives a bunch of squiggly red lines when trying to unpack the return value.

image

This is because .step() is annotated as follow, potentially returning None, which can't be unpacked

def step(self, inputs: Optional[Dict[str, Any]] = None) -> Optional[Tuple[Action, dict, State]]:
   # ...
   return self._step(...)

def _step(
   self, inputs: Optional[Dict[str, Any]], _run_hooks: bool = True
) -> Optional[Tuple[Action, dict, State]]:
   # ... 
   return next_action, result, new_state

(the return line of ._step() also has red squiggly lines)

Does ._step() actually ever return None ? If yes, would it make sense to have it return (None, None, None) instead?

Having two potentially return values (the tuple or None) can be annoying to deal with if they have different "shapes". I'm guessing that directly unpacking the return value is common.

elijahbenizzy commented 1 week ago

OK, so: