| from openai._exceptions import ( |
| APIError, |
| OpenAIError, |
| ConflictError, |
| NotFoundError, |
| APIStatusError, |
| RateLimitError, |
| APITimeoutError, |
| BadRequestError, |
| APIConnectionError, |
| AuthenticationError, |
| InternalServerError, |
| PermissionDeniedError, |
| UnprocessableEntityError, |
| APIResponseValidationError, |
| ) |
| from fastapi import status |
| from requests.exceptions import RequestException |
| error_table = { |
| RequestException: { |
| "status_code": status.HTTP_408_REQUEST_TIMEOUT, |
| "detail": "Los servidores tardaron mucho en responder, puede haber sobrecarga en OpenAI, reintenta luego (error 1)" |
| }, |
| APIConnectionError: { |
| "status_code": status.HTTP_408_REQUEST_TIMEOUT, |
| "detail": "El servidor no respondi贸, hubo un error de API" |
| }, |
| APITimeoutError: { |
| "status_code": status.HTTP_408_REQUEST_TIMEOUT, |
| "detail": "El servidor tard贸 demasiado en responder" |
| }, |
| RateLimitError: { |
| "status_code": status.HTTP_408_REQUEST_TIMEOUT, |
| "detail": "ChatGPT se gomit贸 馃ぎ, este chat ya es muy largo, limpia el chat y reintenta." |
| }, |
| "undefined": { |
| "status_code": status.HTTP_408_REQUEST_TIMEOUT, |
| "detail": "Error no definido 馃檮" |
| } |
| } |
| |