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

Update unit tests to catch up with langchain-core #743

Merged
merged 15 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion langserve/api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from fastapi.exceptions import RequestValidationError
from langchain_core._api.beta_decorator import warn_beta
from langchain_core.callbacks.base import AsyncCallbackHandler
from langchain_core.callbacks.manager import BaseCallbackManager
from langchain_core.load.serializable import Serializable
from langchain_core.runnables import Runnable, RunnableConfig
from langchain_core.runnables.config import (
Expand Down Expand Up @@ -470,7 +471,12 @@ def _add_callbacks(
"""Add the callback aggregator to the config."""
if "callbacks" not in config:
config["callbacks"] = []
config["callbacks"].extend(callbacks)
if "callbacks" in config:
if isinstance(config["callbacks"], list):
config["callbacks"].extend(callbacks)
elif isinstance(config["callbacks"], BaseCallbackManager):
for callback in callbacks:
config["callbacks"].add_handler(callback, inherit=True)


_MODEL_REGISTRY = {}
Expand Down
8 changes: 6 additions & 2 deletions langserve/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,15 @@ def batch(
self,
inputs: List[Input],
config: Optional[RunnableConfig] = None,
*,
return_exceptions: bool = False,
**kwargs: Any,
) -> List[Output]:
if kwargs:
raise NotImplementedError("kwargs not implemented yet.")
return self._batch_with_config(self._batch, inputs, config)
raise NotImplementedError(f"kwargs not implemented yet. Got {kwargs}")
return self._batch_with_config(
self._batch, inputs, config, return_exceptions=return_exceptions
)

async def _abatch(
self,
Expand Down
Loading
Loading