forked from phoenix/litellm-mirror
add moderation
This commit is contained in:
parent
a86ec0f916
commit
d15d876b02
2 changed files with 25 additions and 0 deletions
|
@ -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```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue