fix: Replacing unsafe eval() with json.loads() (#1890)

This commit is contained in:
Patrick Peng 2024-04-30 15:58:19 +08:00 committed by GitHub
parent e21bf20c10
commit 9d0d614706
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -218,7 +218,7 @@ class SagemakerLLM(CustomLLM):
response_body = resp["Body"]
response_str = response_body.read().decode("utf-8")
response_dict = eval(response_str)
response_dict = json.loads(response_str)
return CompletionResponse(
text=response_dict[0]["generated_text"][len(prompt) :], raw=resp