From 0d7601781d3d1d13c5d71ccf846754dd61b717ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A2=E3=83=AA=E3=82=B9?= Date: Thu, 19 Dec 2024 12:08:58 +0900 Subject: [PATCH] update ssl verifying part to work with httpx 0.28.0 (#798) As the new httpx 0.28.0 removes VerifyTypes, we should update to follow their change See [issue](https://github.com/langchain-ai/langserve/issues/796) --------- Co-authored-by: Eugene Yurtsev --- langserve/client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/langserve/client.py b/langserve/client.py index 1dde56c6..93e23919 100644 --- a/langserve/client.py +++ b/langserve/client.py @@ -21,7 +21,7 @@ from urllib.parse import urljoin import httpx -from httpx._types import AuthTypes, CertTypes, CookieTypes, HeaderTypes, VerifyTypes +from httpx._types import AuthTypes, CertTypes, CookieTypes, HeaderTypes from langchain_core.callbacks import ( AsyncCallbackManagerForChainRun, CallbackManagerForChainRun, @@ -49,6 +49,11 @@ logger = logging.getLogger(__name__) +import typing + +if typing.TYPE_CHECKING: # We simply follow the way httpx do + import ssl + def _is_json_serializable(obj: Any) -> bool: """Return True if the object is json serializable.""" @@ -281,7 +286,7 @@ def __init__( auth: Optional[AuthTypes] = None, headers: Optional[HeaderTypes] = None, cookies: Optional[CookieTypes] = None, - verify: VerifyTypes = True, + verify: ssl.SSLContext | str | bool = True, cert: Optional[CertTypes] = None, client_kwargs: Optional[Dict[str, Any]] = None, use_server_callback_events: bool = True,