From 36c0b3dda2ccd9bc2435d6e7d3ffee3bd9c237bd Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Thu, 12 Sep 2024 11:36:55 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A(backend)=20create=20skeleton=20end?= =?UTF-8?q?point=20ai?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create a skeleton endpoint for the AI to rewrite the text sent in the request. We send as well the action to be performed on the text by the AI. --- src/backend/core/api/viewsets.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/backend/core/api/viewsets.py b/src/backend/core/api/viewsets.py index 86fdf059..7db91481 100644 --- a/src/backend/core/api/viewsets.py +++ b/src/backend/core/api/viewsets.py @@ -367,6 +367,21 @@ class DocumentViewSet( pass return drf_response.Response(serializer.data) + + @decorators.action(detail=True, methods=["post"], url_path="ai") + def ai(self, request, *args, **kwargs): + """ + Return the document's versions but only those created after the user got access + to the document + """ + if not request.user.is_authenticated: + raise exceptions.PermissionDenied("Authentication required.") + + action = request.data.get("action") + text = request.data.get("text") + + return drf_response.Response(text.upper()) + @decorators.action(detail=True, methods=["get"], url_path="versions") def versions_list(self, request, *args, **kwargs):