From 6666e422c6ca7a0ac5874025b0cd243ad5b1f865 Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Wed, 5 Jul 2023 19:47:30 +0300 Subject: [PATCH] fix: missing parameter in POST/PUT/PATCH HTTP requests (#7194) @hinthornw --------- Co-authored-by: Harrison Chase --- langchain/requests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/langchain/requests.py b/langchain/requests.py index 567003cb2bf..536687278b3 100644 --- a/langchain/requests.py +++ b/langchain/requests.py @@ -73,7 +73,7 @@ class Requests(BaseModel): self, url: str, data: Dict[str, Any], **kwargs: Any ) -> AsyncGenerator[aiohttp.ClientResponse, None]: """POST to the URL and return the text asynchronously.""" - async with self._arequest("POST", url, **kwargs) as response: + async with self._arequest("POST", url, json=data, **kwargs) as response: yield response @asynccontextmanager @@ -81,7 +81,7 @@ class Requests(BaseModel): self, url: str, data: Dict[str, Any], **kwargs: Any ) -> AsyncGenerator[aiohttp.ClientResponse, None]: """PATCH the URL and return the text asynchronously.""" - async with self._arequest("PATCH", url, **kwargs) as response: + async with self._arequest("PATCH", url, json=data, **kwargs) as response: yield response @asynccontextmanager @@ -89,7 +89,7 @@ class Requests(BaseModel): self, url: str, data: Dict[str, Any], **kwargs: Any ) -> AsyncGenerator[aiohttp.ClientResponse, None]: """PUT the URL and return the text asynchronously.""" - async with self._arequest("PUT", url, **kwargs) as response: + async with self._arequest("PUT", url, json=data, **kwargs) as response: yield response @asynccontextmanager @@ -147,17 +147,17 @@ class TextRequestsWrapper(BaseModel): async def apost(self, url: str, data: Dict[str, Any], **kwargs: Any) -> str: """POST to the URL and return the text asynchronously.""" - async with self.requests.apost(url, **kwargs) as response: + async with self.requests.apost(url, data, **kwargs) as response: return await response.text() async def apatch(self, url: str, data: Dict[str, Any], **kwargs: Any) -> str: """PATCH the URL and return the text asynchronously.""" - async with self.requests.apatch(url, **kwargs) as response: + async with self.requests.apatch(url, data, **kwargs) as response: return await response.text() async def aput(self, url: str, data: Dict[str, Any], **kwargs: Any) -> str: """PUT the URL and return the text asynchronously.""" - async with self.requests.aput(url, **kwargs) as response: + async with self.requests.aput(url, data, **kwargs) as response: return await response.text() async def adelete(self, url: str, **kwargs: Any) -> str: