The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community: Fix #22975 (Add SSL Verification Option to Requests Class in langchain_community) (#22977)
Eun Hye Kim70761af8cfdc
diff --git a/libs/community/langchain_community/utilities/requests.py b/libs/community/langchain_community/utilities/requests.pyindex f265549bd6..9a34556b5e 100644--- a/libs/community/langchain_community/utilities/requests.py+++ b/libs/community/langchain_community/utilities/requests.py@@ -18,6 +18,7 @@ class Requests(BaseModel):headers: Optional[Dict[str, str]] = Noneaiosession: Optional[aiohttp.ClientSession] = Noneauth: Optional[Any] = None+ verify: Optional[bool] = Trueclass Config:"""Configuration for this pydantic object."""@@ -27,29 +28,48 @@ class Requests(BaseModel):def get(self, url: str, **kwargs: Any) -> requests.Response:"""GET the URL and return the text."""- return requests.get(url, headers=self.headers, auth=self.auth, **kwargs)+ return requests.get(+ url, headers=self.headers, auth=self.auth, verify=self.verify, **kwargs+ )def post(self, url: str, data: Dict[str, Any], **kwargs: Any) -> requests.Response:"""POST to the URL and return the text."""return requests.post(- url, json=data, headers=self.headers, auth=self.auth, **kwargs+ url,+ json=data,+ headers=self.headers,+ auth=self.auth,+ verify=self.verify,+ **kwargs,)def patch(self, url: str, data: Dict[str, Any], **kwargs: Any) -> requests.Response:"""PATCH the URL and return the text."""return requests.patch(- url, json=data, headers=self.headers, auth=self.auth, **kwargs+ url,+ json=data,+ headers=self.headers,+ auth=self.auth,+ verify=self.verify,+ **kwargs,)def put(self, url: str, data: Dict[str, Any], **kwargs: Any) -> requests.Response:"""PUT the URL and return the text."""return requests.put(- url, json=data, headers=self.headers, auth=self.auth, **kwargs+ url,+ json=data,+ headers=self.headers,+ auth=self.auth,+ verify=self.verify,+ **kwargs,)def delete(self, url: str, **kwargs: Any) -> requests.Response:"""DELETE the URL and return the text."""- return requests.delete(url, headers=self.headers, auth=self.auth, **kwargs)+ return requests.delete(+ url, headers=self.headers, auth=self.auth, verify=self.verify, **kwargs+ )@asynccontextmanagerasync def _arequest(@@ -59,12 +79,22 @@ class Requests(BaseModel):if not self.aiosession:async with aiohttp.ClientSession() as session:async with session.request(- method, url, headers=self.headers, auth=self.auth, **kwargs+ method,+ url,+ headers=self.headers,+ auth=self.auth,+ verify=self.verify,+ **kwargs,) as response:yield responseelse:async with self.aiosession.request(- method, url, headers=self.headers, auth=self.auth, **kwargs+ method,+ url,+ headers=self.headers,+ auth=self.auth,+ verify=self.verify,+ **kwargs,) as response:yield response@@ -116,6 +146,7 @@ class GenericRequestsWrapper(BaseModel):aiosession: Optional[aiohttp.ClientSession] = Noneauth: Optional[Any] = Noneresponse_content_type: Literal["text", "json"] = "text"+ verify: bool = Trueclass Config:"""Configuration for this pydantic object."""@@ -126,7 +157,10 @@ class GenericRequestsWrapper(BaseModel):@propertydef requests(self) -> Requests:return Requests(- headers=self.headers, aiosession=self.aiosession, auth=self.auth+ headers=self.headers,+ aiosession=self.aiosession,+ auth=self.auth,+ verify=self.verify,)def _get_resp_content(self, response: Response) -> Union[str, Dict[str, Any]]: