1515# Get logger
1616logger = get_logger ("locallab.routes.models" )
1717
18- # Create router
19- router = APIRouter (tags = ["Models" ])
18+ # Create router with prefix
19+ router = APIRouter (
20+ prefix = "/models" ,
21+ tags = ["Models" ]
22+ )
2023
2124class ModelInfo (BaseModel ):
2225 """Model information response"""
@@ -42,7 +45,7 @@ class LoadModelRequest(BaseModel):
4245 """Request model for loading a model"""
4346 model_id : str
4447
45- @router .post ("/models/ load" )
48+ @router .post ("/load" )
4649async def load_model (request : LoadModelRequest ) -> Dict [str , str ]:
4750 """Load a specific model"""
4851 try :
@@ -54,7 +57,7 @@ async def load_model(request: LoadModelRequest) -> Dict[str, str]:
5457 logger .error (f"Failed to load model { request .model_id } : { str (e )} " )
5558 raise HTTPException (status_code = 500 , detail = str (e ))
5659
57- @router .get ("" , response_model = ModelsListResponse )
60+ @router .get ("/list " , response_model = ModelsListResponse )
5861async def list_models () -> ModelsListResponse :
5962 """List all available models"""
6063 models_list = []
@@ -72,14 +75,12 @@ async def list_models() -> ModelsListResponse:
7275 current_model = model_manager .current_model
7376 )
7477
75-
7678@router .get ("/available" , response_model = ModelsListResponse )
7779async def available_models () -> ModelsListResponse :
7880 """List all available models (alternative endpoint)"""
7981 # This endpoint exists to provide compatibility with different API patterns
8082 return await list_models ()
8183
82-
8384@router .get ("/current" , response_model = ModelResponse )
8485async def get_current_model () -> ModelResponse :
8586 """Get information about the currently loaded model"""
@@ -96,7 +97,6 @@ async def get_current_model() -> ModelResponse:
9697 loading_progress = 1.0
9798 )
9899
99-
100100@router .post ("/load/{model_id}" , response_model = Dict [str , str ])
101101async def load_model (model_id : str , background_tasks : BackgroundTasks ) -> Dict [str , str ]:
102102 """Load a specific model"""
@@ -115,7 +115,6 @@ async def load_model(model_id: str, background_tasks: BackgroundTasks) -> Dict[s
115115 logger .error (f"Failed to load model { model_id } : { str (e )} " )
116116 raise HTTPException (status_code = 500 , detail = str (e ))
117117
118-
119118@router .post ("/load" , response_model = Dict [str , str ])
120119async def load_model_from_body (request : LoadModelRequest , background_tasks : BackgroundTasks ) -> Dict [str , str ]:
121120 """Load a specific model using model_id from request body"""
@@ -135,7 +134,6 @@ async def load_model_from_body(request: LoadModelRequest, background_tasks: Back
135134 logger .error (f"Failed to load model { model_id } : { str (e )} " )
136135 raise HTTPException (status_code = 500 , detail = str (e ))
137136
138-
139137@router .post ("/unload" , response_model = Dict [str , str ])
140138async def unload_model () -> Dict [str , str ]:
141139 """Unload the current model to free up resources"""
@@ -150,7 +148,6 @@ async def unload_model() -> Dict[str, str]:
150148 logger .error (f"Failed to unload model: { str (e )} " )
151149 raise HTTPException (status_code = 500 , detail = str (e ))
152150
153-
154151@router .get ("/status/{model_id}" , response_model = ModelResponse )
155152async def get_model_status (model_id : str ) -> ModelResponse :
156153 """Get the loading status of a specific model"""
0 commit comments