mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-25 21:43:57 +01:00
19 lines
379 B
Python
19 lines
379 B
Python
import os
|
|
import asyncio
|
|
import openai as closedai
|
|
|
|
from typing import Union
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
closedai.api_key = os.getenv('LEGIT_CLOSEDAI_KEY')
|
|
|
|
async def is_safe(text: Union[str, list]) -> bool:
|
|
return closedai.Moderation.create(
|
|
input=text,
|
|
)['results'][0]['flagged']
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(is_safe('Hello'))
|