Skip to content

Commit

Permalink
fix(ai-proxy): correct model check precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
ttyS0e committed Jun 5, 2024
1 parent 7b5c6a2 commit f3d71c5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions kong/plugins/ai-proxy/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,20 +343,20 @@ function _M:access(conf)
return bad_request(err)
end

-- check that the user isn't trying to override the plugin conf model in the request body
if request_table and request_table.model and type(request_table.model) == "string" then
if request_table.model ~= conf_m.model.name then
return bad_request("cannot use own model - must be: " .. conf_m.model.name)
end
end

-- copy from the user request if present
if (not multipart) and (not conf_m.model.name) and (request_table.model) then
conf_m.model.name = request_table.model
elseif multipart then
conf_m.model.name = "NOT_SPECIFIED"
end

-- check that the user isn't trying to override the plugin conf model in the request body
if request_table and request_table.model and type(request_table.model) == "string" then
if request_table.model ~= conf_m.model.name then
return bad_request("cannot use own model - must be: " .. conf_m.model.name)
end
end

-- model is stashed in the copied plugin conf, for consistency in transformation functions
if not conf_m.model.name then
return bad_request("model parameter not found in request, nor in gateway configuration")
Expand Down

0 comments on commit f3d71c5

Please sign in to comment.