mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(feat) sagemaker - map status code and message
This commit is contained in:
parent
00ac18e8b7
commit
0e26ef858b
1 changed files with 19 additions and 3 deletions
|
@ -184,7 +184,15 @@ def completion(
|
|||
CustomAttributes="accept_eula=true",
|
||||
)
|
||||
except Exception as e:
|
||||
raise SagemakerError(status_code=500, message=f"{str(e)}")
|
||||
status_code = (
|
||||
getattr(e, "response", {})
|
||||
.get("ResponseMetadata", {})
|
||||
.get("HTTPStatusCode", 500)
|
||||
)
|
||||
error_message = (
|
||||
getattr(e, "response", {}).get("Error", {}).get("Message", str(e))
|
||||
)
|
||||
raise SagemakerError(status_code=status_code, message=error_message)
|
||||
|
||||
response = response["Body"].read().decode("utf8")
|
||||
## LOGGING
|
||||
|
@ -358,7 +366,15 @@ def embedding(
|
|||
CustomAttributes="accept_eula=true",
|
||||
)
|
||||
except Exception as e:
|
||||
raise SagemakerError(status_code=500, message=f"{str(e)}")
|
||||
status_code = (
|
||||
getattr(e, "response", {})
|
||||
.get("ResponseMetadata", {})
|
||||
.get("HTTPStatusCode", 500)
|
||||
)
|
||||
error_message = (
|
||||
getattr(e, "response", {}).get("Error", {}).get("Message", str(e))
|
||||
)
|
||||
raise SagemakerError(status_code=status_code, message=error_message)
|
||||
|
||||
response = json.loads(response["Body"].read().decode("utf8"))
|
||||
## LOGGING
|
||||
|
@ -368,7 +384,7 @@ def embedding(
|
|||
original_response=response,
|
||||
additional_args={"complete_input_dict": data},
|
||||
)
|
||||
|
||||
|
||||
print_verbose(f"raw model_response: {response}")
|
||||
if "embedding" not in response:
|
||||
raise SagemakerError(status_code=500, message="embedding not found in response")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue