You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to improve our application's error handling by catching requests for unsupported model types and returning informative error responses. This will help users quickly understand when they're trying to use a model type that our system doesn't support.
Objective:
Create a mechanism to check if a requested model type is supported, and if not, return a clear error response.
Tasks:
Create a list or set of supported model types in config.py.
Implement a function to check if a given model type is supported.
Modify the model loading or request handling process to use this check.
Create a custom exception for unsupported model types.
Update the API to catch this exception and return an appropriate HTTP response.
Example Implementation:
# In utils.pyMODELS= { "lm": ["gpt2", "bert", "t5", "llama"], "vlm": ["llava"]}
# In utils.pyfromfastapiimportHTTPExceptionclassUnsupportedModelTypeError(Exception):
passdefis_supported_model_type(model_type: str) ->bool:
returnmodel_type.lower() inMODELSdefcheck_model_type(model_type: str) ->None:
ifnotis_supported_model_type(model_type):
raiseUnsupportedModelTypeError(f"Model type '{model_type}' is not supported")
# In main.py or wherever model loading occursfromfastapiimportHTTPException@app.post("/v1/load_model")asyncdefload_model(model_type: str, model_name: str):
try:
check_model_type(model_type)
# Proceed with model loadingexceptUnsupportedModelTypeErrorase:
raiseHTTPException(status_code=400, detail=str(e))
Guidelines:
Keep the implementation simple and focused on the core functionality.
Ensure that the check for supported model types is case-insensitive.
Use clear and descriptive error messages.
Consider adding logging for unsupported model type requests.
Think about where in the request lifecycle this check should occur.
Function to check for supported model types is created and working.
Custom exception for unsupported model types is implemented.
API endpoints are updated to use the new check and handle the custom exception.
Appropriate HTTP responses are returned for unsupported model types.
Basic logging for unsupported model type requests is implemented.
Code is commented and follows our style guide.
We're looking forward to your contribution! This feature will greatly improve the user experience by providing clear feedback when unsupported model types are requested. If you have any questions or need clarification, please don't hesitate to ask in the comments. Good luck!
The text was updated successfully, but these errors were encountered:
Description:
We need to improve our application's error handling by catching requests for unsupported model types and returning informative error responses. This will help users quickly understand when they're trying to use a model type that our system doesn't support.
Objective:
Create a mechanism to check if a requested model type is supported, and if not, return a clear error response.
Tasks:
config.py
.Example Implementation:
Guidelines:
Resources:
Definition of Done:
We're looking forward to your contribution! This feature will greatly improve the user experience by providing clear feedback when unsupported model types are requested. If you have any questions or need clarification, please don't hesitate to ask in the comments. Good luck!
The text was updated successfully, but these errors were encountered: