Spaces:
Sleeping
Sleeping
Update private_gpt/launcher.py
Browse files- private_gpt/launcher.py +5 -6
private_gpt/launcher.py
CHANGED
@@ -99,7 +99,7 @@ def create_app(root_injector: Injector) -> FastAPI:
|
|
99 |
status_code=status.HTTP_403_FORBIDDEN,
|
100 |
detail="You are not authorized to use this API.",
|
101 |
)
|
102 |
-
|
103 |
# Retrieve model information and validate access
|
104 |
model_info = next((m for m in models_data if m["name"] == new_model), None)
|
105 |
if not model_info or current_user.get("role") not in model_info["access"]:
|
@@ -107,17 +107,16 @@ def create_app(root_injector: Injector) -> FastAPI:
|
|
107 |
status_code=status.HTTP_403_FORBIDDEN,
|
108 |
detail="You are not authorized to access this model.",
|
109 |
)
|
110 |
-
|
111 |
# Switch the model using the LLMComponent
|
112 |
llm_component = root_injector.get(LLMComponent)
|
113 |
-
|
114 |
-
|
115 |
-
llm_component.switch_model(new_model)
|
116 |
-
|
117 |
# Return a success message
|
118 |
return {"message": f"Model switched to {new_model}"}
|
119 |
|
120 |
|
|
|
121 |
# Define a new APIRouter for the model_list
|
122 |
model_list_router = APIRouter(prefix="/v1", dependencies=[Depends(get_current_user)])
|
123 |
|
|
|
99 |
status_code=status.HTTP_403_FORBIDDEN,
|
100 |
detail="You are not authorized to use this API.",
|
101 |
)
|
102 |
+
|
103 |
# Retrieve model information and validate access
|
104 |
model_info = next((m for m in models_data if m["name"] == new_model), None)
|
105 |
if not model_info or current_user.get("role") not in model_info["access"]:
|
|
|
107 |
status_code=status.HTTP_403_FORBIDDEN,
|
108 |
detail="You are not authorized to access this model.",
|
109 |
)
|
110 |
+
|
111 |
# Switch the model using the LLMComponent
|
112 |
llm_component = root_injector.get(LLMComponent)
|
113 |
+
llm_component.switch_model(new_model, settings)
|
114 |
+
|
|
|
|
|
115 |
# Return a success message
|
116 |
return {"message": f"Model switched to {new_model}"}
|
117 |
|
118 |
|
119 |
+
|
120 |
# Define a new APIRouter for the model_list
|
121 |
model_list_router = APIRouter(prefix="/v1", dependencies=[Depends(get_current_user)])
|
122 |
|