1+ --
2+ -- Licensed to the Apache Software Foundation (ASF) under one or more
3+ -- contributor license agreements. See the NOTICE file distributed with
4+ -- this work for additional information regarding copyright ownership.
5+ -- The ASF licenses this file to You under the Apache License, Version 2.0
6+ -- (the "License"); you may not use this file except in compliance with
7+ -- the License. You may obtain a copy of the License at
8+ --
9+ -- http://www.apache.org/licenses/LICENSE-2.0
10+ --
11+ -- Unless required by applicable law or agreed to in writing, software
12+ -- distributed under the License is distributed on an "AS IS" BASIS,
13+ -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ -- See the License for the specific language governing permissions and
15+ -- limitations under the License.
16+ --
117local core = require (" apisix.core" )
218local ngx = ngx
319
4157local function get_content_to_check (conf , messages )
4258 local contents = {}
4359 if conf .match_all_conversation_history then
44- core .log .warn (" Matching all conversation history" )
4560 for _ , msg in ipairs (messages ) do
4661 if msg .content then
4762 core .table .insert (contents , msg .content )
6176function _M .access (conf , ctx )
6277 local body = core .request .get_body ()
6378 if not body then
64- core .log .error (" Empty request body" )
79+ core .log .error (" Empty request body" )
6580 return core .response .exit (400 , {message = " Empty request body" })
6681 end
6782
@@ -72,9 +87,9 @@ function _M.access(conf, ctx)
7287
7388
7489 local messages = json_body .messages or {}
75- if not conf .match_all_roles and messages and messages [# messages ].role ~= " user" then
76- return
77- end
90+ if not conf .match_all_roles and messages and messages [# messages ].role ~= " user" then
91+ return
92+ end
7893 local content_to_check = get_content_to_check (conf , messages )
7994
8095 -- Allow patterns check
0 commit comments