Skip to content
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
33 changes: 26 additions & 7 deletions app/api/endpoints/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
Model listing endpoints (OpenAI compatibility)
"""

from time import time

from fastapi import APIRouter

from app.models import ModelsResponse, ModelInfo
from app.core import add_route_aliases
from app.core.tts_model import get_model_info

# Create router with aliasing support
base_router = APIRouter()
Expand All @@ -19,18 +22,34 @@
description="List available models (OpenAI API compatibility)"
)
async def list_models():
"""List available models (OpenAI API compatibility)"""
"""List currently loaded models (OpenAI API compatibility)."""
runtime_model_info = get_model_info()

if not runtime_model_info["is_ready"]:
return ModelsResponse(object="list", data=[])

model_type = runtime_model_info["model_type"]
model_id = (
"chatterbox-tts-multilingual-1"
if runtime_model_info["is_multilingual"]
else "chatterbox-tts-standard-1"
)

return ModelsResponse(
object="list",
data=[
ModelInfo(
id="chatterbox-tts-1",
object="model",
created=1677649963,
owned_by="resemble-ai"
id=model_id,
object="model",
created=int(time()),
owned_by="resemble-ai",
ready=True,
device=runtime_model_info["device"],
model_type=model_type,
language_count=runtime_model_info["language_count"],
)
]
],
)

# Export the base router for the main app to use
__all__ = ["base_router"]
__all__ = ["base_router"]
6 changes: 5 additions & 1 deletion app/models/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class ModelInfo(BaseModel):
object: str
created: int
owned_by: str
ready: Optional[bool] = None
device: Optional[str] = None
model_type: Optional[str] = None
language_count: Optional[int] = None


class ModelsResponse(BaseModel):
Expand Down Expand Up @@ -181,4 +185,4 @@ class DefaultVoiceResponse(BaseModel):
default_voice: Optional[str]
source: str
voice_info: Optional[VoiceLibraryItem] = None
path: Optional[str] = None
path: Optional[str] = None
Loading