feat(core): trace response body on error (#32653)

This commit is contained in:
ccurme
2025-08-25 15:28:19 -03:00
committed by GitHub
parent 1c55536ec1
commit f33480c2cf

View File

@@ -78,6 +78,11 @@ def _generate_response_from_error(error: BaseException) -> list[ChatGeneration]:
if hasattr(error, "response"):
response = error.response
metadata: dict = {}
if hasattr(response, "json"):
try:
metadata["body"] = response.json()
except Exception:
metadata["body"] = getattr(response, "text", None)
if hasattr(response, "headers"):
try:
metadata["headers"] = dict(response.headers)