Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created a proxy endpoint for xlit api #1123

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/tasks/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
AnnotationViewSet,
PredictionViewSet,
get_celery_tasks,
TransliterationAPIView,
)

router = routers.DefaultRouter()
Expand All @@ -15,4 +16,9 @@

urlpatterns = [
path("get_celery_tasks/", get_celery_tasks),
path(
"xlit-api/generic/transliteration/<str:target_language>/<str:data>",
TransliterationAPIView.as_view(),
name="transliteration-api",
),
] + router.urls
14 changes: 14 additions & 0 deletions backend/tasks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import sacrebleu

from utils.date_time_conversions import utc_to_ist
from rest_framework.views import APIView

# Create your views here.

Expand Down Expand Up @@ -2642,3 +2643,16 @@ def get_celery_tasks(request):
page_size = int(request.GET.get("page_size", 10))
data = paginate_queryset(filtered_tasks, page_number, page_size)
return JsonResponse(data["results"], safe=False)


class TransliterationAPIView(APIView):
permission_classes = [IsAuthenticated]

def get(self, request, target_language, data, *args, **kwargs):
response_transliteration = requests.get(
os.getenv("TRANSLITERATION_URL") + target_language + "/" + data,
headers={"Authorization": "Bearer " + os.getenv("TRANSLITERATION_KEY")},
)

transliteration_output = response_transliteration.json()
return Response(transliteration_output, status=status.HTTP_200_OK)
Loading