From 799c3d2451beb0fc03b6ff41ba430018d4c4bbbd Mon Sep 17 00:00:00 2001 From: Wangchong Zhou Date: Mon, 23 Sep 2024 18:48:12 +0800 Subject: [PATCH] fix(llm): remove multi-modal restriction on pre request check --- .../kong/fix-ai-proxy-multi-modal-azure.yml | 4 ++++ kong/llm/drivers/shared.lua | 19 ------------------- 2 files changed, 4 insertions(+), 19 deletions(-) create mode 100644 changelog/unreleased/kong/fix-ai-proxy-multi-modal-azure.yml diff --git a/changelog/unreleased/kong/fix-ai-proxy-multi-modal-azure.yml b/changelog/unreleased/kong/fix-ai-proxy-multi-modal-azure.yml new file mode 100644 index 000000000000..91ad71617543 --- /dev/null +++ b/changelog/unreleased/kong/fix-ai-proxy-multi-modal-azure.yml @@ -0,0 +1,4 @@ +message: | + **AI-Proxy**: Fixed issue where multi-modal requests is blocked on azure provider. +type: bugfix +scope: Plugin diff --git a/kong/llm/drivers/shared.lua b/kong/llm/drivers/shared.lua index f408b671b633..829e10988185 100644 --- a/kong/llm/drivers/shared.lua +++ b/kong/llm/drivers/shared.lua @@ -604,20 +604,6 @@ function _M.resolve_plugin_conf(kong_request, conf) end -local function check_multi_modal(conf, request_table) - if not request_table.messages or (conf.model.provider == "openai" or conf.model.provider == "bedrock" ) then - return true - end - - for _, m in ipairs(request_table.messages) do - if type(m.content) == "table" then - return false - end - end - - return true -end - function _M.pre_request(conf, request_table) -- process form/json body auth information local auth_param_name = conf.auth and conf.auth.param_name @@ -636,11 +622,6 @@ function _M.pre_request(conf, request_table) return nil, "no plugin name is being passed by the plugin" end - local ok = check_multi_modal(conf, request_table) - if not ok then - return kong.response.exit("multi-modal input is not supported by current provider") - end - -- if enabled AND request type is compatible, capture the input for analytics if conf.logging and conf.logging.log_payloads then kong.log.set_serialize_value(fmt("ai.%s.%s.%s", plugin_name, log_entry_keys.PAYLOAD_CONTAINER, log_entry_keys.REQUEST_BODY), kong.request.get_raw_body())