Fedir Zadniprovskyi commited on
Commit
9c0d580
·
1 Parent(s): dc4f25f

fix: models route returning non-asr models

Browse files
faster_whisper_server/main.py CHANGED
@@ -86,7 +86,7 @@ def health() -> Response:
86
 
87
  @app.get("/v1/models")
88
  def get_models() -> list[ModelObject]:
89
- models = huggingface_hub.list_models(library="ctranslate2")
90
  models = [
91
  ModelObject(
92
  id=model.id,
@@ -105,7 +105,9 @@ def get_models() -> list[ModelObject]:
105
  def get_model(
106
  model_name: Annotated[str, Path(example="Systran/faster-distil-whisper-large-v3")],
107
  ) -> ModelObject:
108
- models = list(huggingface_hub.list_models(model_name=model_name, library="ctranslate2"))
 
 
109
  if len(models) == 0:
110
  raise HTTPException(status_code=404, detail="Model doesn't exists")
111
  exact_match: ModelInfo | None = None
 
86
 
87
  @app.get("/v1/models")
88
  def get_models() -> list[ModelObject]:
89
+ models = huggingface_hub.list_models(library="ctranslate2", tags="automatic-speech-recognition")
90
  models = [
91
  ModelObject(
92
  id=model.id,
 
105
  def get_model(
106
  model_name: Annotated[str, Path(example="Systran/faster-distil-whisper-large-v3")],
107
  ) -> ModelObject:
108
+ models = list(
109
+ huggingface_hub.list_models(model_name=model_name, library="ctranslate2", tags="automatic-speech-recognition")
110
+ )
111
  if len(models) == 0:
112
  raise HTTPException(status_code=404, detail="Model doesn't exists")
113
  exact_match: ModelInfo | None = None
tests/api_model_test.py CHANGED
@@ -4,7 +4,7 @@ from faster_whisper_server.server_models import ModelObject
4
 
5
  MODEL_THAT_EXISTS = "Systran/faster-whisper-tiny.en"
6
  MODEL_THAT_DOES_NOT_EXIST = "i-do-not-exist"
7
- MIN_EXPECTED_NUMBER_OF_MODELS = 200 # At the time of the test creation there are 228 models
8
 
9
 
10
  # HACK: because ModelObject(**data) doesn't work
 
4
 
5
  MODEL_THAT_EXISTS = "Systran/faster-whisper-tiny.en"
6
  MODEL_THAT_DOES_NOT_EXIST = "i-do-not-exist"
7
+ MIN_EXPECTED_NUMBER_OF_MODELS = 70 # At the time of the test creation there are 89 models
8
 
9
 
10
  # HACK: because ModelObject(**data) doesn't work