language models and set defaults are updated

This commit is contained in:
2025-01-28 17:11:59 +03:00
parent c0bd9c1685
commit 5d3f946642
34 changed files with 638 additions and 126 deletions

View File

@@ -14,14 +14,18 @@ class BaseEndpointResponse:
from Services.Redis import RedisActions
from ApiLayers.AllConfigs.Redis.configs import RedisValidationKeys
language_model_key = f"{RedisValidationKeys.LANGUAGE_MODELS}:{RedisValidationKeys.RESPONSES}"
language_model = RedisActions.get_json(list_keys=[language_model_key, self.code, self.lang])
language_model_key = (
f"{RedisValidationKeys.LANGUAGE_MODELS}:{RedisValidationKeys.RESPONSES}"
)
language_model = RedisActions.get_json(
list_keys=[language_model_key, self.code, self.lang]
)
if language_model.status:
return language_model.first.as_dict
return {"message": f"{self.code} -> Language model not found"}
class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
@@ -30,7 +34,7 @@ class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
)
class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
@@ -39,7 +43,7 @@ class EndpointCreatedResponse(BaseEndpointResponse): # 201 Create
)
class EndpointAcceptedResponse(BaseEndpointResponse): # 202 Accepted
class EndpointAcceptedResponse(BaseEndpointResponse): # 202 Accepted
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
@@ -48,7 +52,7 @@ class EndpointAcceptedResponse(BaseEndpointResponse): # 202 Accep
)
class EndpointNotModifiedResponse(BaseEndpointResponse): # 304 Not Modified
class EndpointNotModifiedResponse(BaseEndpointResponse): # 304 Not Modified
def as_dict(self):
return JSONResponse(
@@ -57,7 +61,7 @@ class EndpointNotModifiedResponse(BaseEndpointResponse): # 304 Not
)
class EndpointBadRequestResponse(BaseEndpointResponse): # 400 Bad Request
class EndpointBadRequestResponse(BaseEndpointResponse): # 400 Bad Request
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
@@ -66,7 +70,7 @@ class EndpointBadRequestResponse(BaseEndpointResponse): # 400 Bad R
)
class EndpointUnauthorizedResponse(BaseEndpointResponse): # 401 Unauthorized
class EndpointUnauthorizedResponse(BaseEndpointResponse): # 401 Unauthorized
def as_dict(self):
return JSONResponse(
@@ -75,7 +79,7 @@ class EndpointUnauthorizedResponse(BaseEndpointResponse): # 401 Unaut
)
class EndpointForbiddenResponse(BaseEndpointResponse): # 403 Forbidden
class EndpointForbiddenResponse(BaseEndpointResponse): # 403 Forbidden
def as_dict(self):
return JSONResponse(
@@ -84,7 +88,7 @@ class EndpointForbiddenResponse(BaseEndpointResponse): # 403 Forbi
)
class EndpointNotFoundResponse(BaseEndpointResponse): # 404 Not Found
class EndpointNotFoundResponse(BaseEndpointResponse): # 404 Not Found
def as_dict(self):
return JSONResponse(
@@ -93,7 +97,7 @@ class EndpointNotFoundResponse(BaseEndpointResponse): # 404 Not F
)
class EndpointMethodNotAllowedResponse(BaseEndpointResponse): # 405 Method Not Allowed
class EndpointMethodNotAllowedResponse(BaseEndpointResponse): # 405 Method Not Allowed
def as_dict(self):
return JSONResponse(
@@ -102,7 +106,7 @@ class EndpointMethodNotAllowedResponse(BaseEndpointResponse): # 405 Metho
)
class EndpointNotAcceptableResponse(BaseEndpointResponse): # 406 Not Acceptable
class EndpointNotAcceptableResponse(BaseEndpointResponse): # 406 Not Acceptable
def as_dict(self):
return JSONResponse(
@@ -111,7 +115,7 @@ class EndpointNotAcceptableResponse(BaseEndpointResponse): # 406 Not A
)
class EndpointConflictResponse(BaseEndpointResponse): # 409 Conflict
class EndpointConflictResponse(BaseEndpointResponse): # 409 Conflict
def as_dict(self):
return JSONResponse(
@@ -120,7 +124,9 @@ class EndpointConflictResponse(BaseEndpointResponse): # 409 Confli
)
class EndpointUnprocessableEntityResponse(BaseEndpointResponse): # 422 Unprocessable Entity
class EndpointUnprocessableEntityResponse(
BaseEndpointResponse
): # 422 Unprocessable Entity
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
@@ -129,7 +135,7 @@ class EndpointUnprocessableEntityResponse(BaseEndpointResponse): # 422 Unpro
)
class EndpointTooManyRequestsResponse(BaseEndpointResponse): # 429 Too Many Requests
class EndpointTooManyRequestsResponse(BaseEndpointResponse): # 429 Too Many Requests
def __init__(self, retry_after: int, lang: str, code: str):
super().__init__(lang=lang, code=code)
@@ -143,7 +149,7 @@ class EndpointTooManyRequestsResponse(BaseEndpointResponse): # 429 Too M
)
class EndpointInternalErrorResponse(BaseEndpointResponse): # 500 Internal Server Error
class EndpointInternalErrorResponse(BaseEndpointResponse): # 500 Internal Server Error
def as_dict(self):
return JSONResponse(