Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more information error if APIHandler receives a non runnable object. #385

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions langserve/api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,16 @@ def __init__(

self._config_keys = config_keys

if not isinstance(runnable, Runnable):
raise TypeError(
f"Expected a Runnable got {type(runnable)} which does not "
"inherit from Runnable. It looks like you're trying to use a "
"an object which is not a runnable as a runnable, which will "
"not work. You could try using a RunnableLambda to create "
"a runnable for your code or else create a Runnable subclass and"
"place the appropriate logic there."
)

self._path = path
self._base_url = prefix + path
self._include_callback_events = include_callback_events
Expand Down