From 60d65209631c0ad9e772d1a63e9cf22a287f8918 Mon Sep 17 00:00:00 2001 From: MarkRx Date: Fri, 27 Dec 2024 11:09:00 -0700 Subject: [PATCH] Fix python async client not filtering out params with None values --- python/langsmith/async_client.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/langsmith/async_client.py b/python/langsmith/async_client.py index 7573e7c80..35cee5f3d 100644 --- a/python/langsmith/async_client.py +++ b/python/langsmith/async_client.py @@ -96,6 +96,14 @@ async def _arequest_with_retries( ) -> httpx.Response: """Make an async HTTP request with retries.""" max_retries = cast(int, self._retry_config.get("max_retries", 3)) + + # Python requests library used by the normal Client filters out params with None values + # The httpx library does not. Filter them out here to keep behavior consistent + if 'params' in kwargs: + params = kwargs['params'] + filtered_params = {k: v for k, v in params.items() if v is not None} + kwargs['params'] = filtered_params + for attempt in range(max_retries): try: response = await self._client.request(method, endpoint, **kwargs)