diff --git a/libs/community/langchain_community/chat_models/pai_eas_endpoint.py b/libs/community/langchain_community/chat_models/pai_eas_endpoint.py index a8b5d6d293725..cc3867717e973 100644 --- a/libs/community/langchain_community/chat_models/pai_eas_endpoint.py +++ b/libs/community/langchain_community/chat_models/pai_eas_endpoint.py @@ -228,6 +228,25 @@ def _call_eas(self, query_body: dict) -> bytes: ) return response.content + """Generate text from the eas service.""" + headers = { + "Content-Type": "application/json", + "Accept": "application/json", + "Authorization": f"{self.eas_service_token}", + } + + # make request + response = requests.post( + self.eas_service_url, headers=headers, json=query_body, timeout=self.timeout + ) + + if response.status_code != 200: + raise Exception( + f"Request failed with status code {response.status_code}" + f" and message {response.text}" + ) + + return response.content def _call_eas_stream(self, query_body: dict) -> Any: """Generate text from the eas service."""