Commit Graph
1 Commits
Author SHA1 Message Date
8e611b42aa Fix bug in add_conditional_edges when no path_map is provided (#809)
* Fix bug in add_conditional_edges when no path_map is provided

When an instance of a callable class is passed as the path arg to
add_conditional_edges but no path_map is provided, get_type_hints(path) is
called, which raises a TypeError (since get_type_hints only accepts a module,
class, method, or function).

This patch fixes the error by trying to get type hints from path.__call__ first,
which should work for instances of callable classes.

Tested: Added a test that raises TypeError without the fix in this patch but
passes with the fix.

* More defensive, additional test

---------

Co-authored-by: Nuno Campos <nuno@langchain.dev>
2024-06-26 16:24:59 -07:00