Fedir Zadniprovskyi 2024-07-03
fix: models route returning non-asr models
@3e501dd2d4472f199deeb969633400197d3b5aa8
faster_whisper_server/main.py
--- faster_whisper_server/main.py
+++ faster_whisper_server/main.py
@@ -86,7 +86,7 @@
 
 @app.get("/v1/models")
 def get_models() -> list[ModelObject]:
-    models = huggingface_hub.list_models(library="ctranslate2")
+    models = huggingface_hub.list_models(library="ctranslate2", tags="automatic-speech-recognition")
     models = [
         ModelObject(
             id=model.id,
@@ -105,7 +105,9 @@
 def get_model(
     model_name: Annotated[str, Path(example="Systran/faster-distil-whisper-large-v3")],
 ) -> ModelObject:
-    models = list(huggingface_hub.list_models(model_name=model_name, library="ctranslate2"))
+    models = list(
+        huggingface_hub.list_models(model_name=model_name, library="ctranslate2", tags="automatic-speech-recognition")
+    )
     if len(models) == 0:
         raise HTTPException(status_code=404, detail="Model doesn't exists")
     exact_match: ModelInfo | None = None
tests/api_model_test.py
--- tests/api_model_test.py
+++ tests/api_model_test.py
@@ -4,7 +4,7 @@
 
 MODEL_THAT_EXISTS = "Systran/faster-whisper-tiny.en"
 MODEL_THAT_DOES_NOT_EXIST = "i-do-not-exist"
-MIN_EXPECTED_NUMBER_OF_MODELS = 200  # At the time of the test creation there are 228 models
+MIN_EXPECTED_NUMBER_OF_MODELS = 70  # At the time of the test creation there are 89 models
 
 
 # HACK: because ModelObject(**data) doesn't work
Add a comment
List