(exc: httpx.TransportError)
| 4970 | return status_code in (400, 404, 422) and _is_model_error(content) |
| 4971 | |
| 4972 | def _transport_error_response(exc: httpx.TransportError) -> httpx.Response: |
| 4973 | status_code = 504 if isinstance(exc, httpx.TimeoutException) else 502 |
| 4974 | error_type = "timeout" if status_code == 504 else "proxy_error" |
| 4975 | if status_code == 504: |
| 4976 | message = "Upstream request timed out" |
| 4977 | elif isinstance(exc, httpx.ConnectError): |
| 4978 | message = f"Upstream unreachable: {upstream_chat}" |
| 4979 | else: |
| 4980 | message = "Upstream disconnected before sending a response" |
| 4981 | detail = str(exc).strip() |
| 4982 | if detail: |
| 4983 | message = f"{message}: {detail}" |
| 4984 | return httpx.Response( |
| 4985 | status_code, |
| 4986 | json={"error": {"message": message, "type": error_type}}, |
| 4987 | ) |
| 4988 | |
| 4989 | async def _post_non_stream_attempt(attempt_payload: dict[str, Any]) -> httpx.Response: |
| 4990 | try: |
no outgoing calls
no test coverage detected