From 7433df5d7489919d1ed9d86dbdb2b6f70288219d Mon Sep 17 00:00:00 2001 From: Azalea Gui <22280294+hykilpikonna@users.noreply.github.com> Date: Mon, 20 Apr 2026 01:32:54 -0400 Subject: [PATCH] [O] Dockerize AI github moderator --- tools/gh_moderator.dockerfile | 18 ++++++++++++++++++ tools/gh_moderator.example.toml | 10 +++++++--- tools/gh_moderator.py | 2 -- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 tools/gh_moderator.dockerfile diff --git a/tools/gh_moderator.dockerfile b/tools/gh_moderator.dockerfile new file mode 100644 index 00000000..a565fb36 --- /dev/null +++ b/tools/gh_moderator.dockerfile @@ -0,0 +1,18 @@ +FROM python:3.12-slim + +WORKDIR /app + +# Install dependencies +RUN pip install openai pygithub fastapi uvicorn hypy_utils hatchling + +# Copy source code +COPY . . + +# Set environment variables +ENV PYTHONUNBUFFERED=true +ENV PYTHONPATH=/app + +# The app looks for config at ~/.config/gh_moderator.toml +# We will mount it via compose + +CMD ["uvicorn", "tools.gh_moderator:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/tools/gh_moderator.example.toml b/tools/gh_moderator.example.toml index 133428b2..727780fc 100644 --- a/tools/gh_moderator.example.toml +++ b/tools/gh_moderator.example.toml @@ -5,6 +5,10 @@ webhook_secret = "secret" gh_token = "token" gh_repo = "owner/repo" -# AI harm classifier token -harm_classifier_url = "https://example.com/classify" -harm_classifier_token = "token" + + +[OpenAI] +org = "your-org-id" +key = "your-api-key" +model = "omni-moderation-latest" +threshold = 0.7 diff --git a/tools/gh_moderator.py b/tools/gh_moderator.py index 7d8b5891..dafe80de 100644 --- a/tools/gh_moderator.py +++ b/tools/gh_moderator.py @@ -37,8 +37,6 @@ me = gh.get_user() repo = gh.get_repo(config["gh_repo"]) printc(f"&a[+] Logged in as {me.login}") -harm_classifier_url, harm_classifier_token = config["harm_classifier_url"], config["harm_classifier_token"] - script_path = Path(__file__).parent supported_events = ["issue_comment", "issues", "pull_request", "pull_request_review_comment"] ai_notice = f"If you think this is a false-positive, please contact the owner of this repo."