Skip to content

Commit

Permalink
qxqx
Browse files Browse the repository at this point in the history
  • Loading branch information
eyurtsev committed Sep 12, 2024
1 parent 4b0bd08 commit 45ddb62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion langserve/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def __init__(
cert: Optional[CertTypes] = None,
client_kwargs: Optional[Dict[str, Any]] = None,
use_server_callback_events: bool = True,
serializer: Optional[Serializer] = None,
) -> None:
"""Initialize the client.
Expand All @@ -300,6 +301,8 @@ def __init__(
and async httpx clients
use_server_callback_events: Whether to invoke callbacks on any
callback events returned by the server.
serializer: The serializer to use for serializing and deserializing
data. If not provided, a default serializer will be used.
"""
_client_kwargs = client_kwargs or {}
# Enforce trailing slash
Expand Down Expand Up @@ -327,7 +330,7 @@ def __init__(

# Register cleanup handler once RemoteRunnable is garbage collected
weakref.finalize(self, _close_clients, self.sync_client, self.async_client)
self._lc_serializer = WellKnownLCSerializer()
self._lc_serializer = serializer or WellKnownLCSerializer()
self._use_server_callback_events = use_server_callback_events

def _invoke(
Expand Down
5 changes: 5 additions & 0 deletions langserve/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
TokenFeedbackConfig,
_is_hosted,
)
from langserve.serialization import Serializer

try:
from fastapi import APIRouter, Depends, FastAPI, Request, Response
Expand Down Expand Up @@ -263,6 +264,7 @@ def add_routes(
dependencies: Optional[Sequence[Depends]] = None,
playground_type: Literal["default", "chat"] = "default",
astream_events_version: Literal["v1", "v2"] = "v2",
serializer: Optional[Serializer] = None,
) -> None:
"""Register the routes on the given FastAPI app or APIRouter.
Expand Down Expand Up @@ -383,6 +385,8 @@ def add_routes(
which message types are supported etc.)
astream_events_version: version of the stream events endpoint to use.
By default "v2".
serializer: The serializer to use for serializing the output. If not provided,
the default serializer will be used.
""" # noqa: E501
if not isinstance(runnable, Runnable):
raise TypeError(
Expand Down Expand Up @@ -447,6 +451,7 @@ def add_routes(
stream_log_name_allow_list=stream_log_name_allow_list,
playground_type=playground_type,
astream_events_version=astream_events_version,
serializer=serializer,
)

namespace = path or ""
Expand Down

0 comments on commit 45ddb62

Please sign in to comment.