15
15
# Get logger
16
16
logger = get_logger ("locallab.routes.models" )
17
17
18
- # Create router
19
- router = APIRouter (tags = ["Models" ])
18
+ # Create router with prefix
19
+ router = APIRouter (
20
+ prefix = "/models" ,
21
+ tags = ["Models" ]
22
+ )
20
23
21
24
class ModelInfo (BaseModel ):
22
25
"""Model information response"""
@@ -42,7 +45,7 @@ class LoadModelRequest(BaseModel):
42
45
"""Request model for loading a model"""
43
46
model_id : str
44
47
45
- @router .post ("/models/ load" )
48
+ @router .post ("/load" )
46
49
async def load_model (request : LoadModelRequest ) -> Dict [str , str ]:
47
50
"""Load a specific model"""
48
51
try :
@@ -54,7 +57,7 @@ async def load_model(request: LoadModelRequest) -> Dict[str, str]:
54
57
logger .error (f"Failed to load model { request .model_id } : { str (e )} " )
55
58
raise HTTPException (status_code = 500 , detail = str (e ))
56
59
57
- @router .get ("" , response_model = ModelsListResponse )
60
+ @router .get ("/list " , response_model = ModelsListResponse )
58
61
async def list_models () -> ModelsListResponse :
59
62
"""List all available models"""
60
63
models_list = []
@@ -72,14 +75,12 @@ async def list_models() -> ModelsListResponse:
72
75
current_model = model_manager .current_model
73
76
)
74
77
75
-
76
78
@router .get ("/available" , response_model = ModelsListResponse )
77
79
async def available_models () -> ModelsListResponse :
78
80
"""List all available models (alternative endpoint)"""
79
81
# This endpoint exists to provide compatibility with different API patterns
80
82
return await list_models ()
81
83
82
-
83
84
@router .get ("/current" , response_model = ModelResponse )
84
85
async def get_current_model () -> ModelResponse :
85
86
"""Get information about the currently loaded model"""
@@ -96,7 +97,6 @@ async def get_current_model() -> ModelResponse:
96
97
loading_progress = 1.0
97
98
)
98
99
99
-
100
100
@router .post ("/load/{model_id}" , response_model = Dict [str , str ])
101
101
async def load_model (model_id : str , background_tasks : BackgroundTasks ) -> Dict [str , str ]:
102
102
"""Load a specific model"""
@@ -115,7 +115,6 @@ async def load_model(model_id: str, background_tasks: BackgroundTasks) -> Dict[s
115
115
logger .error (f"Failed to load model { model_id } : { str (e )} " )
116
116
raise HTTPException (status_code = 500 , detail = str (e ))
117
117
118
-
119
118
@router .post ("/load" , response_model = Dict [str , str ])
120
119
async def load_model_from_body (request : LoadModelRequest , background_tasks : BackgroundTasks ) -> Dict [str , str ]:
121
120
"""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
135
134
logger .error (f"Failed to load model { model_id } : { str (e )} " )
136
135
raise HTTPException (status_code = 500 , detail = str (e ))
137
136
138
-
139
137
@router .post ("/unload" , response_model = Dict [str , str ])
140
138
async def unload_model () -> Dict [str , str ]:
141
139
"""Unload the current model to free up resources"""
@@ -150,7 +148,6 @@ async def unload_model() -> Dict[str, str]:
150
148
logger .error (f"Failed to unload model: { str (e )} " )
151
149
raise HTTPException (status_code = 500 , detail = str (e ))
152
150
153
-
154
151
@router .get ("/status/{model_id}" , response_model = ModelResponse )
155
152
async def get_model_status (model_id : str ) -> ModelResponse :
156
153
"""Get the loading status of a specific model"""
0 commit comments