129: Refactoring decorators - #188
JaeYeonLee0621 wants to merge 2 commits into
Conversation
| ) | ||
| from gateway.decorators.responses import check_tool_availability, validate_response_id | ||
|
|
||
| __all__ = [ |
There was a problem hiding this comment.
Should we use __all__ here? I guess we just assume we want to export everything and we still have private functions with _. This is always more work with little gain.
| return wrapper | ||
|
|
||
|
|
||
| def check_limits(view_func: AsyncView) -> AsyncView: |
There was a problem hiding this comment.
I think check_limits should not belong to auth. As we already have plans to expand how we handle limits, this should get its own file I think.
| return False | ||
|
|
||
|
|
||
| def normalize_reasoning_fields(view_func: AsyncView) -> AsyncView: |
There was a problem hiding this comment.
Tangential but do we really only need to normalize reasoning fields for chat completions and not responses? I forgot but maybe the Responses was unified from the beginning anyways.
There was a problem hiding this comment.
I do not really like the name of the file. Should we have a types.py file? Or leave it in utils.py? Basically can you check how many custom utility classes and functions we have/expect to have and split accordingly?
| return status_map.get(status, "invalid_request_error") | ||
|
|
||
|
|
||
| def in_wildcard(value: str | None, allowed_values: list[str]) -> bool: |
There was a problem hiding this comment.
This is probably a util function right?
| return valid | ||
|
|
||
|
|
||
| def register_response_in_cache(response_id: str | None, model: str, email: str) -> None: |
There was a problem hiding this comment.
This and the following functions are specific to the Responses API and not related to Django HTTP responses at all so these should be moved.
1. Decorators refactored
Split the large
gateway/views/decorators.pyinto a newgateway/decorators/package with one module per concern:The old
gateway/views/decorators.pywas deleted.2. Review opinions applied
check_mcp_server_availabilitymoved intomcp.py.get_relay_model_nameremoved (it was unused).process_file_contentandnormalize_reasoning_fieldsgrouped inchat_completions.py.Utility functionsplaced next to the decorators that use them, rather than in a separate utils module.