Skip to content

Add api_key parameter to Moderation.create #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openai/api_resources/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ 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."
)

instance = cls()
instance = cls(api_key=api_key)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we only have this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean removing other linting changes? I removed them now.

params = {"input": input}
if model is not None:
params["model"] = model
Expand Down