Skip to content

Commit

Permalink
Fix return type of _call_eas to bytes as per issue langchain-ai#20453
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangfuqiang01 committed Aug 21, 2024
1 parent 3ea4db3 commit 5b79162
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions libs/community/langchain_community/chat_models/pai_eas_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit 5b79162

Please sign in to comment.