ruanweihong-aaa commented on code in PR #14073:
URL: https://github.com/apache/apisix/pull/14073#discussion_r4408779499
##########
apisix/plugins/ai-prompt-guard.lua:
##########
@@ -142,11 +142,20 @@ function _M.access(conf, ctx)
return
end
- local messages = protocols.get_messages(json_body, ctx)
+ local messages
+ if proto_name == "openai-embeddings" then
+ local contents =
protocols.get(proto_name).extract_request_content(json_body)
+ messages = {}
+ for i, content in ipairs(contents) do
+ messages[i] = {role = "user", content = content}
+ end
Review Comment:
Updated in 98625024dde3be6df7f3ac33b0861f47a3ced787: moved the array
handling into `openai-embeddings.get_messages()` while keeping all batch items
checked by `ai-prompt-guard`.
Potential impacts:
1. **ai-cache**: Existing cached array requests may miss the cache until new
entries are populated.
2. **ai-proxy-multi**: With semantic routing enabled, the last non-empty
text in the array is used for matching, which may change the selected model.
--
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]