(
error: RoutingInfeasibleError,
*,
api_format: str = "openai",
)
| 1973 | |
| 1974 | |
| 1975 | def _routing_infeasible_payload( |
| 1976 | error: RoutingInfeasibleError, |
| 1977 | *, |
| 1978 | api_format: str = "openai", |
| 1979 | ) -> dict[str, Any]: |
| 1980 | detail = error.infeasibility.as_dict() |
| 1981 | code = str(detail.pop("code")) |
| 1982 | message = str(detail.pop("message")) |
| 1983 | if api_format == "anthropic": |
| 1984 | body = anthropic_error_response(400, message) |
| 1985 | body["error"]["code"] = code |
| 1986 | if detail: |
| 1987 | body["error"]["details"] = detail |
| 1988 | return body |
| 1989 | payload: dict[str, Any] = { |
| 1990 | "error": { |
| 1991 | "message": message, |
| 1992 | "type": "routing_infeasible", |
| 1993 | "code": code, |
| 1994 | }, |
| 1995 | } |
| 1996 | if detail: |
| 1997 | payload["error"]["details"] = detail |
| 1998 | return payload |
| 1999 | |
| 2000 | |
| 2001 | def _routing_infeasible_response( |
no test coverage detected