From 4886249efa1d1d88563d9272f5ee4a36277dd2ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zafer=20=C3=87avdar?= Date: Sat, 17 Sep 2022 02:23:50 +0300 Subject: [PATCH 1/2] Add api_key parameter to Moderation.create --- openai/api_resources/moderation.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openai/api_resources/moderation.py b/openai/api_resources/moderation.py index 12a4e19d7e..1ed14ace8f 100644 --- a/openai/api_resources/moderation.py +++ b/openai/api_resources/moderation.py @@ -4,21 +4,23 @@ class Moderation(OpenAIObject): - VALID_MODEL_NAMES: List[str] = ["text-moderation-stable", "text-moderation-latest"] + VALID_MODEL_NAMES: List[str] = [ + "text-moderation-stable", "text-moderation-latest"] @classmethod def get_url(self): return "/moderations" @classmethod - def create(cls, input: Union[str, List[str]], model: Optional[str] = None): + def create(cls, input: Union[str, List[str]], model: Optional[str] = None, + api_key: Optional[str] = None): if model is not None and model not in cls.VALID_MODEL_NAMES: raise ValueError( f"The parameter model should be chosen from {cls.VALID_MODEL_NAMES} " - f"and it is default to be None." + f"and it is default to be None.", ) - instance = cls() + instance = cls(api_key=api_key) params = {"input": input} if model is not None: params["model"] = model From d486548a5e677c65d78086bafd9bc89311a1f7dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zafer=20=C3=87avdar?= Date: Sun, 18 Sep 2022 11:14:30 +0300 Subject: [PATCH 2/2] Reverted auto-formatted linting --- openai/api_resources/moderation.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/openai/api_resources/moderation.py b/openai/api_resources/moderation.py index 1ed14ace8f..52f997fb26 100644 --- a/openai/api_resources/moderation.py +++ b/openai/api_resources/moderation.py @@ -4,20 +4,18 @@ class Moderation(OpenAIObject): - VALID_MODEL_NAMES: List[str] = [ - "text-moderation-stable", "text-moderation-latest"] + VALID_MODEL_NAMES: List[str] = ["text-moderation-stable", "text-moderation-latest"] @classmethod def get_url(self): return "/moderations" @classmethod - def create(cls, input: Union[str, List[str]], model: Optional[str] = None, - api_key: Optional[str] = None): + def create(cls, input: Union[str, List[str]], model: Optional[str] = None, api_key: Optional[str] = None): if model is not None and model not in cls.VALID_MODEL_NAMES: raise ValueError( f"The parameter model should be chosen from {cls.VALID_MODEL_NAMES} " - f"and it is default to be None.", + f"and it is default to be None." ) instance = cls(api_key=api_key)