Commit 24fc6924

Lilian <lilian@openai.com>
2022-06-15 13:43:38
v0.20.1: patch how model is handled in moderation endpoint. (#102) tag: v0.20.0
1 parent 3852e25
Changed files (1)
openai
api_resources
openai/api_resources/moderation.py
@@ -12,11 +12,14 @@ class Moderation(OpenAIObject):
 
     @classmethod
     def create(cls, input: Union[str, List[str]], model: Optional[str] = None):
-        if model not in cls.VALID_MODEL_NAMES:
+        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."
             )
 
         instance = cls()
-        return instance.request("post", cls.get_url(), {"input": input, "model": model})
+        params = {"input": input}
+        if model is not None:
+            params["model"] = model
+        return instance.request("post", cls.get_url(), params)