nic-6443 commented on code in PR #14073:
URL: https://github.com/apache/apisix/pull/14073#discussion_r4396174482


##########
apisix/plugins/ai-prompt-guard.lua:
##########
@@ -142,7 +142,19 @@ function _M.access(conf, ctx)
         return
     end
 
-    local messages = protocols.get_messages(json_body, ctx)
+    local messages
+    if proto_name == "openai-embeddings" then
+        -- A batch contains independent inputs, not conversation history. Keep
+        -- all its text in one user message so the last-message filter below
+        -- cannot discard earlier inputs.
+        local contents = 
protocols.get(proto_name).extract_request_content(json_body)
+        messages = {}
+        if #contents > 0 then
+            messages[1] = {role = "user", content = table.concat(contents, " 
")}
+        end

Review Comment:
   Isn't the `openai-response` below the same? Can it be placed together with 
the existing judgment branches?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to