ruanweihong-aaa commented on code in PR #14073:
URL: https://github.com/apache/apisix/pull/14073#discussion_r4396233592


##########
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:
   Updated in 8aa196bb: Embeddings now shares the history-filtering condition 
with Responses, while retaining extraction and inspection of all batch strings. 
The embeddings and existing guard tests pass (52 + 170 assertions).



-- 
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