Ykeremy/separate sonnet prompt (#263)

This commit is contained in:
Kerem Yilmaz
2024-05-06 13:07:52 -07:00
committed by GitHub
parent ccd435dd82
commit 25ac637b40
3 changed files with 94 additions and 1 deletions

View File

@@ -6,10 +6,20 @@ LOG = structlog.get_logger()
class BaseExperimentationProvider(ABC):
# feature_name -> distinct_id -> result
result_map: dict[str, dict[str, bool]] = {}
@abstractmethod
def is_feature_enabled(self, feature_name: str, distinct_id: str) -> bool:
"""Check if a specific feature is enabled."""
def is_feature_enabled_cached(self, feature_name: str, distinct_id: str) -> bool:
if feature_name not in self.result_map:
self.result_map[feature_name] = {}
if distinct_id not in self.result_map[feature_name]:
self.result_map[feature_name][distinct_id] = self.is_feature_enabled(feature_name, distinct_id)
return self.result_map[feature_name][distinct_id]
class NoOpExperimentationProvider(BaseExperimentationProvider):
def is_feature_enabled(self, feature_name: str, distinct_id: str) -> bool: