Merge pull request 'Remove moderation POST' (#1) from pr/remove-api-post into master
Reviewed-on: #1
This commit is contained in:
commit
b3ceb47ae5
@ -30,9 +30,6 @@ DISCORD_CLIENT_SECRET=YOUR_DISCORD_APP_CLIENT_SECRET
|
|||||||
DISCORD_REDIRECT_URI=YOUR_DISCORD_APP_REDIRECT_URI
|
DISCORD_REDIRECT_URI=YOUR_DISCORD_APP_REDIRECT_URI
|
||||||
FLASK_SECRET_KEY=YOUR_FLASK_SECRET_KEY_HERE # Used for session management in Flask server
|
FLASK_SECRET_KEY=YOUR_FLASK_SECRET_KEY_HERE # Used for session management in Flask server
|
||||||
|
|
||||||
# Secret key for AI moderation API endpoint
|
|
||||||
MOD_LOG_API_SECRET=YOUR_MOD_LOG_API_SECRET_HERE
|
|
||||||
|
|
||||||
# API Server Base URL (For Discord Sync Cog)
|
# API Server Base URL (For Discord Sync Cog)
|
||||||
API_BASE_URL=http://127.0.0.1:5001 # Example URL for the API server
|
API_BASE_URL=http://127.0.0.1:5001 # Example URL for the API server
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ from . import aimod_config as aimod_config_module
|
|||||||
from .aimod_config import (
|
from .aimod_config import (
|
||||||
DEFAULT_VERTEX_AI_MODEL,
|
DEFAULT_VERTEX_AI_MODEL,
|
||||||
STANDARD_SAFETY_SETTINGS,
|
STANDARD_SAFETY_SETTINGS,
|
||||||
MOD_LOG_API_SECRET_ENV_VAR,
|
|
||||||
GUILD_CONFIG_PATH,
|
GUILD_CONFIG_PATH,
|
||||||
USER_INFRACTIONS_PATH,
|
USER_INFRACTIONS_PATH,
|
||||||
INFRACTION_BACKUP_DIR,
|
INFRACTION_BACKUP_DIR,
|
||||||
@ -1919,51 +1918,6 @@ CRITICAL: Do NOT output anything other than the required JSON response.
|
|||||||
# Get the model from guild config, fall back to global default
|
# Get the model from guild config, fall back to global default
|
||||||
model_used = get_guild_config(guild_id, "AI_MODEL", DEFAULT_VERTEX_AI_MODEL)
|
model_used = get_guild_config(guild_id, "AI_MODEL", DEFAULT_VERTEX_AI_MODEL)
|
||||||
|
|
||||||
# --- Transmit action info over HTTP POST ---
|
|
||||||
try:
|
|
||||||
mod_log_api_secret = os.getenv("MOD_LOG_API_SECRET")
|
|
||||||
if mod_log_api_secret:
|
|
||||||
post_url = f"https://slipstreamm.dev/dashboard/api/guilds/{guild_id}/ai-moderation-action" # will be replaceing later with the Learnhelp API
|
|
||||||
payload = {
|
|
||||||
"timestamp": current_timestamp_iso,
|
|
||||||
"guild_id": guild_id,
|
|
||||||
"guild_name": message.guild.name,
|
|
||||||
"channel_id": message.channel.id,
|
|
||||||
"channel_name": message.channel.name,
|
|
||||||
"message_id": message.id,
|
|
||||||
"message_link": message.jump_url,
|
|
||||||
"user_id": user_id,
|
|
||||||
"user_name": str(message.author),
|
|
||||||
"action": action, # This will be the AI suggested action before potential overrides
|
|
||||||
"rule_violated": rule_violated,
|
|
||||||
"reasoning": reasoning,
|
|
||||||
"violation": ai_decision.get("violation", False),
|
|
||||||
"message_content": (
|
|
||||||
message.content[:1024] if message.content else ""
|
|
||||||
),
|
|
||||||
"full_message_content": message.content if message.content else "",
|
|
||||||
"ai_model": model_used,
|
|
||||||
"result": "pending_system_action", # Indicates AI decision received, system action pending
|
|
||||||
}
|
|
||||||
headers = {
|
|
||||||
"Authorization": f"Bearer {mod_log_api_secret}",
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
}
|
|
||||||
async with aiohttp.ClientSession() as http_session: # Renamed session to avoid conflict
|
|
||||||
async with http_session.post(
|
|
||||||
post_url, headers=headers, json=payload, timeout=10
|
|
||||||
) as resp:
|
|
||||||
# This payload is just for the initial AI decision log
|
|
||||||
# The actual outcome will be logged after the action is performed
|
|
||||||
if resp.status >= 400:
|
|
||||||
print(
|
|
||||||
f"Failed to POST initial AI decision log: {resp.status}"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
print("MOD_LOG_API_SECRET not set; skipping initial action POST.")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Failed to POST initial action info: {e}")
|
|
||||||
|
|
||||||
# --- Adjust action for first-time offenses ---
|
# --- Adjust action for first-time offenses ---
|
||||||
user_history_list = get_user_infraction_history(guild_id, user_id)
|
user_history_list = get_user_infraction_history(guild_id, user_id)
|
||||||
if action == "BAN" and not user_history_list:
|
if action == "BAN" and not user_history_list:
|
||||||
|
@ -25,7 +25,6 @@ STANDARD_SAFETY_SETTINGS = [
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
MOD_LOG_API_SECRET_ENV_VAR = "MOD_LOG_API_SECRET"
|
|
||||||
|
|
||||||
GUILD_CONFIG_DIR = "data/"
|
GUILD_CONFIG_DIR = "data/"
|
||||||
GUILD_CONFIG_PATH = os.path.join(GUILD_CONFIG_DIR, "guild_config.json")
|
GUILD_CONFIG_PATH = os.path.join(GUILD_CONFIG_DIR, "guild_config.json")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user