Skip to content

Commit

Permalink
Update unit tests to catch up with langchain-core (#743)
Browse files Browse the repository at this point in the history
Updating the unit tests to catch up with langchain-core. No adjustements
should be necessary to user code, the issues manifest themselves only with the
given test set up (e.g., snapshots). langchain-core changes were either
additive or self-consistent.
  • Loading branch information
eyurtsev authored Sep 6, 2024
1 parent d4704c2 commit 41a9d79
Show file tree
Hide file tree
Showing 4 changed files with 1,145 additions and 1,200 deletions.
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

0 comments on commit 41a9d79

Please sign in to comment.