Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ai-content-moderation): add debug log to record moderation results #11996

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apisix/plugins/ai-content-moderation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ function _M.rewrite(conf, ctx)
return HTTP_INTERNAL_SERVER_ERROR, "failed to get moderation results from response"
end

core.log.debug("moderation results: ", core.json.delay_encode(results, true))

for _, result in ipairs(results) do
if conf.moderation_categories then
for _, item in pairs(result.Labels) do
Expand Down
3 changes: 3 additions & 0 deletions t/plugin/ai-content-moderation.t
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ request body exceeds PROFANITY threshold


=== TEST 12: good_request should pass
--- log_level: debug
--- request
POST /echo
{"model":"gpt-4o-mini","messages":[{"role":"user","content":"good_request"}]}
--- error_code: 200
--- error_log eval
qr/moderation results:.*"Toxicity":0.02150000333786.*/
Loading