File size: 1,272 Bytes
019764a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
af2012f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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 馃檮"
    }
}