diff --git a/.flake8 b/.flake8 index dfad8ce..ef09c1c 100644 --- a/.flake8 +++ b/.flake8 @@ -7,4 +7,5 @@ exclude = venv ignore = - E501 \ No newline at end of file + E501 + W291 \ No newline at end of file diff --git a/ai_api/admin.py b/ai_api/admin.py index 8c38f3f..0f0864f 100644 --- a/ai_api/admin.py +++ b/ai_api/admin.py @@ -1,3 +1,3 @@ -from django.contrib import admin +# from django.contrib import admin -# Register your models here. +# # Register your models here. diff --git a/ai_api/models.py b/ai_api/models.py index 71a8362..fd5e269 100644 --- a/ai_api/models.py +++ b/ai_api/models.py @@ -1,3 +1,3 @@ -from django.db import models +# from django.db import models -# Create your models here. +# # Create your models here. diff --git a/ai_api/serializers.py b/ai_api/serializers.py index e6d06b0..b5e134d 100644 --- a/ai_api/serializers.py +++ b/ai_api/serializers.py @@ -3,9 +3,11 @@ class AutocompleteTaskSerializer(serializers.Serializer): text = serializers.CharField() - + # check if the status is completed, then the text should not be empty def validate(self, data): if not data["text"]: - raise serializers.ValidationError("Text is required when status is completed") + raise serializers.ValidationError( + "Text is required when status is completed" + ) return data diff --git a/ai_api/views.py b/ai_api/views.py index ef8abb0..466b010 100644 --- a/ai_api/views.py +++ b/ai_api/views.py @@ -24,6 +24,7 @@ def get(self, request, *args, **kwargs): title = request.query_params.get("title", "") list_tasks = request.query_params.get("list_tasks", "") list_tasks = list_tasks.split(",") if list_tasks else [] + print(list_tasks, input_text, title) if not input_text or not title: return Response( @@ -46,6 +47,7 @@ def get(self, request, *args, **kwargs): ], ) except Exception as e: + print(e) return Response( {"error": "Internal server error"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR, @@ -56,10 +58,12 @@ def get(self, request, *args, **kwargs): print(completion) if "status" not in completion: return Response( - {"error": "There is an error building completion"}, status=status.HTTP_400_BAD_REQUEST + {"error": "There is an error building completion"}, + status=status.HTTP_400_BAD_REQUEST, ) completion_json = json.loads(completion) except (KeyError, json.JSONDecodeError) as e: + print(e) return Response( {"error": "Invalid response from chat completion"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR, @@ -67,7 +71,8 @@ def get(self, request, *args, **kwargs): if completion_json.get("status") == "error": return Response( - {"error": completion_json["message"]}, status=status.HTTP_400_BAD_REQUEST + {"error": completion_json["message"]}, + status=status.HTTP_400_BAD_REQUEST, ) text = completion_json.get("text", "") diff --git a/tests/ai_api/test_ai_autocomplete.py b/tests/ai_api/test_ai_autocomplete.py index 11ea02b..0a585bd 100644 --- a/tests/ai_api/test_ai_autocomplete.py +++ b/tests/ai_api/test_ai_autocomplete.py @@ -1,5 +1,4 @@ import pytest -import re from rest_framework import status from django.urls import reverse