Commit 24fc6924
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)