diff --git a/facefusion/apis/endpoints/state.py b/facefusion/apis/endpoints/state.py index 031bb84d..61c17925 100644 --- a/facefusion/apis/endpoints/state.py +++ b/facefusion/apis/endpoints/state.py @@ -34,9 +34,10 @@ async def set_state(request : Request) -> Response: 'message': translator.get('invalid_state_key', 'facefusion.apis') }, status_code = HTTP_400_BAD_REQUEST) + choices = capability_store.get_api_capability_set().get(key).get('choices') __value__ = cast_argument_value(key, value) - if not validate_argument_value(key, __value__): + if not validate_argument_value(key, __value__) or choices and __value__ not in choices: return JSONResponse( { 'message': translator.get('invalid_state_value', 'facefusion.apis') diff --git a/facefusion/apis/state_helper.py b/facefusion/apis/state_helper.py index f7700e24..e7f0ccb3 100644 --- a/facefusion/apis/state_helper.py +++ b/facefusion/apis/state_helper.py @@ -12,6 +12,9 @@ def validate_argument_value(key : StateKey, value : StateValue) -> bool: if State.__annotations__.get(key) is bool: return isinstance(value, bool) + if State.__annotations__.get(key) is list: + return isinstance(value, list) + return True @@ -23,9 +26,6 @@ def cast_argument_value(key : StateKey, value : StateValue) -> StateValue: return cast_float(value) if State.__annotations__.get(key) is bool: - if isinstance(value, bool): - return value - return cast_bool(value) return value