From 89bb439d62efecc88ecc84c2a5aecc00260c299b Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Thu, 30 Mar 2023 02:04:41 +0530 Subject: [PATCH] chore: return user request count from logger (#596) --- apiserver/plane/api/views/gpt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apiserver/plane/api/views/gpt.py b/apiserver/plane/api/views/gpt.py index 8a138fb89..6e31c89cb 100644 --- a/apiserver/plane/api/views/gpt.py +++ b/apiserver/plane/api/views/gpt.py @@ -28,6 +28,8 @@ class GPTIntegrationEndpoint(BaseAPIView): status=status.HTTP_400_BAD_REQUEST, ) + count = 0 + # If logger is enabled check for request limit if settings.LOGGER_BASE_URL: try: @@ -40,6 +42,7 @@ class GPTIntegrationEndpoint(BaseAPIView): json={"user_id": str(request.user.id)}, headers=headers, ) + count = response.json().get("count", 0) if not response.json().get("success", False): return Response( { @@ -71,11 +74,10 @@ class GPTIntegrationEndpoint(BaseAPIView): text = response.choices[0].text.strip() text_html = text.replace("\n", "
") return Response( - {"response": text, "response_html": text_html}, + {"response": text, "response_html": text_html, "count": count}, status=status.HTTP_200_OK, ) except Exception as e: - print(e) capture_exception(e) return Response( {"error": "Something went wrong please try again later"},