-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
functional api: Add ability to request previous output (#3025)
1. The inputs into foo do not affect any state behavior 2. `previous` always reflects the previous return value from the function 3. Anything can be returned and that will be the new state for the function on the next iteration 4. This API is not meant to support reducers in the inputs/state ```python from langgraph.func import entrypoint states = [] # In this version reducers do not work @entrypoint(checkpointer=MemorySaver()) def foo(inputs, *, previous: Any) -> Any: states.append(previous) return {"previous": previous, "current": inputs} config = {"configurable": {"thread_id": "1"}} foo.invoke({"a": "1"}, config) foo.invoke({"a": "2"}, config) foo.invoke({"a": "3"}, config) assert states == [ None, {"current": {"a": "1"}, "previous": None}, {"current": {"a": "2"}, "previous": {"current": {"a": "1"}, "previous": None}}, ] ```
- Loading branch information
Showing
7 changed files
with
308 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.