From 5166649eae07ef5ee3e33dcf4b7f67d7747bbb5e Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Mon, 11 Nov 2024 09:42:14 -0800 Subject: [PATCH] Cleaner EE fallback for no op (#3106) * treat async values differently * cleaner approach * spacing * typing --- backend/danswer/utils/variable_functionality.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/danswer/utils/variable_functionality.py b/backend/danswer/utils/variable_functionality.py index e542d8fd362..66cb4c3582a 100644 --- a/backend/danswer/utils/variable_functionality.py +++ b/backend/danswer/utils/variable_functionality.py @@ -1,5 +1,6 @@ import functools import importlib +import inspect from typing import Any from typing import TypeVar @@ -139,8 +140,19 @@ def fetch_ee_implementation_or_noop( Exception: If EE is enabled but the fetch fails. """ if not global_version.is_ee_version(): - return lambda *args, **kwargs: noop_return_value + if inspect.iscoroutinefunction(noop_return_value): + async def async_noop(*args: Any, **kwargs: Any) -> Any: + return await noop_return_value(*args, **kwargs) + + return async_noop + + else: + + def sync_noop(*args: Any, **kwargs: Any) -> Any: + return noop_return_value + + return sync_noop try: return fetch_versioned_implementation(module, attribute) except Exception as e: