Skip to content

Commit

Permalink
Added Support for No Service Id for Models
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanks0465 committed Aug 30, 2024
1 parent ec8d002 commit 55ce721
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions backend/areas/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Register your models here.
from .models import Dataset, Tool, Model,News



class NewsAdmin(admin.ModelAdmin):
search_fields=["title"]

Expand Down
1 change: 1 addition & 0 deletions backend/areas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import date



class Area(models.TextChoices):
ASR = "ASR"
NMT = "NMT"
Expand Down
24 changes: 13 additions & 11 deletions backend/areas/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 55ce721

Please sign in to comment.