mirror of
https://github.com/makeplane/plane.git
synced 2025-12-25 16:19:43 +01:00
chore: return gpt response in html (#555)
* chore: return gpt response in html * chore: update the response br
This commit is contained in:
@@ -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", "<br/>")
|
||||
return Response(
|
||||
{"response": text, "response_html": text_html},
|
||||
status=status.HTTP_200_OK,
|
||||
)
|
||||
except Exception as e:
|
||||
capture_exception(e)
|
||||
return Response(
|
||||
|
||||
Reference in New Issue
Block a user