From 3bebcc4714624f32d97c4c6db367607a9cf464a5 Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Wed, 29 Mar 2023 00:23:02 +0530 Subject: [PATCH] chore: return gpt response in html (#555) * chore: return gpt response in html * chore: update the response br --- apiserver/plane/api/views/gpt.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apiserver/plane/api/views/gpt.py b/apiserver/plane/api/views/gpt.py index c470593bf..bdc060e4f 100644 --- a/apiserver/plane/api/views/gpt.py +++ b/apiserver/plane/api/views/gpt.py @@ -28,10 +28,9 @@ class GPTIntegrationEndpoint(BaseAPIView): prompt = request.data.get("prompt", False) task = request.data.get("task", False) - if not prompt or not task: + if not task: return Response( - {"error": "Task and prompt are required"}, - status=status.HTTP_400_BAD_REQUEST, + {"error": "Task is required"}, status=status.HTTP_400_BAD_REQUEST ) final_text = task + "\n" + prompt @@ -45,7 +44,11 @@ class GPTIntegrationEndpoint(BaseAPIView): ) text = response.choices[0].text.strip() - return Response({"response": text}, status=status.HTTP_200_OK) + text_html = text.replace("\n", "
") + return Response( + {"response": text, "response_html": text_html}, + status=status.HTTP_200_OK, + ) except Exception as e: capture_exception(e) return Response(