add moderation

This commit is contained in:
ishaan-jaff 2023-09-19 21:44:04 -07:00
parent a86ec0f916
commit d15d876b02
2 changed files with 25 additions and 0 deletions

View file

@ -1266,6 +1266,22 @@ def text_completion(*args, **kwargs):
kwargs.pop("prompt")
return completion(*args, **kwargs)
##### Moderation #######################
def moderation(*args, **kwargs):
# only supports open ai for now
api_key = None
if "api_key" in kwargs:
api_key = kwargs["api_key"]
api_key = (
api_key or
litellm.api_key or
litellm.openai_key or
get_secret("OPENAI_API_KEY")
)
openai.api_key = api_key
response = openai.Moderation.create(*args, **kwargs)
return response
####### HELPER FUNCTIONS ################
## Set verbose to true -> ```litellm.set_verbose = True```