Skip to content

Commit

Permalink
feat: fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
oowl committed Aug 14, 2024
1 parent 33fca9e commit 2f5f764
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kong/llm/schemas/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ return {
{ logging = logging_schema },
},
entity_checks = {
{ conditional = { if_field = "model.provider",
if_match = { one_of = { "bedrock", "gemini" } },
then_field = "auth.allow_auth_override",
then_match = { eq = false },
then_err = "bedrock and gemini only support auth.allow_auth_override = false" }},
{ mutually_required = { "auth.header_name", "auth.header_value" }, },
{ mutually_required = { "auth.param_name", "auth.param_value", "auth.param_location" }, },

Expand Down
55 changes: 55 additions & 0 deletions spec/03-plugins/38-ai-proxy/00-config_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,59 @@ describe(PLUGIN_NAME .. ": (schema)", function()
assert.is_truthy(ok)
end)

it("bedrock model can not support ath.allowed_auth_override", function()
local config = {
route_type = "llm/v1/chat",
auth = {
param_name = "apikey",
param_value = "key",
param_location = "query",
header_name = "Authorization",
header_value = "Bearer token",
allow_auth_override = true,
},
model = {
name = "bedrock",
provider = "bedrock",
options = {
max_tokens = 256,
temperature = 1.0,
upstream_url = "http://nowhere",
},
},
}

local ok, err = validate(config)

assert.is_falsy(ok)
assert.is_truthy(err)
end)

it("gemini model can not support ath.allowed_auth_override", function()
local config = {
route_type = "llm/v1/chat",
auth = {
param_name = "apikey",
param_value = "key",
param_location = "query",
header_name = "Authorization",
header_value = "Bearer token",
allow_auth_override = true,
},
model = {
name = "gemini",
provider = "gemini",
options = {
max_tokens = 256,
temperature = 1.0,
upstream_url = "http://nowhere",
},
},
}

local ok, err = validate(config)

assert.is_falsy(ok)
assert.is_truthy(err)
end)
end)

0 comments on commit 2f5f764

Please sign in to comment.