Skip to content

Commit

Permalink
config: allow disabling content moderation
Browse files Browse the repository at this point in the history
  • Loading branch information
ProducerMatt committed Sep 20, 2023
1 parent abf80dc commit a3f968e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
gpt4_whitelist_role_ids,
bot_vip_ids,
paid_service_all_channels,
use_helicone
use_helicone,
disable_prompt_moderation
)
from structlog import get_logger
from servicemodules.serviceConstants import Services, openai_channel_ids
Expand Down Expand Up @@ -63,6 +64,9 @@ def is_text_risky(self, text: str) -> bool:
See https://platform.openai.com/docs/guides/moderation/quickstart for details"""

if disable_prompt_moderation:
return False

if CURL_REQUEST:
try:
http_response = requests.post(
Expand Down
3 changes: 3 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def getenv_unique_set(var_name: str, default: T = frozenset()) -> Union[frozense
be_shy: bool
channel_whitelist: Optional[frozenset[str]]
bot_error_channel_id: str
disable_prompt_moderation: bool

is_rob_server = getenv_bool("IS_ROB_SERVER")
if is_rob_server:
Expand Down Expand Up @@ -220,6 +221,7 @@ def getenv_unique_set(var_name: str, default: T = frozenset()) -> Union[frozense
"production": "1017527224540344380",
"development": "1017531179664150608"
}[ENVIRONMENT_TYPE]
disable_prompt_moderation = False
else:
# user-configured from dotenv
discord_guild = getenv("DISCORD_GUILD")
Expand Down Expand Up @@ -259,6 +261,7 @@ def getenv_unique_set(var_name: str, default: T = frozenset()) -> Union[frozense
be_shy = getenv_bool("BE_SHY")
channel_whitelist = getenv_unique_set("CHANNEL_WHITELIST", None)
bot_error_channel_id = getenv("BOT_ERROR_CHANNEL_ID", bot_private_channel_id)
disable_prompt_moderation = getenv_bool("DISABLE_PROMPT_MODERATION")

discord_token: str = getenv("DISCORD_TOKEN")
database_path: str = getenv("DATABASE_PATH")
Expand Down

0 comments on commit a3f968e

Please sign in to comment.