diff --git a/backend/areas/admin.py b/backend/areas/admin.py index e596dea..b5c017e 100644 --- a/backend/areas/admin.py +++ b/backend/areas/admin.py @@ -3,6 +3,8 @@ # Register your models here. from .models import Dataset, Tool, Model,News + + class NewsAdmin(admin.ModelAdmin): search_fields=["title"] diff --git a/backend/areas/models.py b/backend/areas/models.py index 4f73f24..bf5fa06 100644 --- a/backend/areas/models.py +++ b/backend/areas/models.py @@ -2,6 +2,7 @@ from datetime import date + class Area(models.TextChoices): ASR = "ASR" NMT = "NMT" diff --git a/backend/areas/views.py b/backend/areas/views.py index ada43be..6e7ddaa 100644 --- a/backend/areas/views.py +++ b/backend/areas/views.py @@ -128,25 +128,27 @@ def retrieve(self, request, *args, **kwargs): serializer = self.get_serializer(model) modelData = serializer.data hfData = requests.get(f"https://huggingface.co/api/models/{modelData['hf_id']}") - dhruvaModelData = requests.post(DHRUVA_MODEL_VIEW_URL, + + if "service_id" in modelData and modelData["service_id"]!=None: + dhruvaModelData = requests.post(DHRUVA_MODEL_VIEW_URL, headers= {'x-auth-source': 'API_KEY', 'Authorization': DHRUVA_API_KEY}, json={'serviceId':modelData["service_id"]}).json()["model"] - languages = dhruvaModelData["languages"] - task = dhruvaModelData["task"]["type"] + languages = dhruvaModelData["languages"] + task = dhruvaModelData["task"]["type"] - sourceLanguages = list(set([x["sourceLanguage"] for x in languages])) - if "targetLanguage" in languages[0]: - targetLanguages = list(set([x["targetLanguage"] for x in languages])) - else: - targetLanguages = [] + sourceLanguages = list(set([x["sourceLanguage"] for x in languages])) + if "targetLanguage" in languages[0]: + targetLanguages = list(set([x["targetLanguage"] for x in languages])) + else: + targetLanguages = [] - modelData["hfData"] = hfData.json() - modelData["languageFilters"] = {"sourceLanguages":sourceLanguages,"targetLanguages":targetLanguages} + modelData["languageFilters"] = {"sourceLanguages":sourceLanguages,"targetLanguages":targetLanguages} - + modelData["hfData"] = hfData.json() + return Response(modelData)