Skip to content

Commit f271392

Browse files
authored
fix(ai-proxy): correct logging schema key in ai-proxy-multi (#12795)
1 parent 827d4ba commit f271392

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

apisix/plugins/ai-proxy/schema.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ _M.ai_proxy_multi_schema = {
194194
default = { algorithm = "roundrobin" }
195195
},
196196
instances = ai_instance_schema,
197-
logging_schema = logging_schema,
197+
logging = logging_schema,
198198
fallback_strategy = {
199199
anyOf = {
200200
{

t/plugin/ai-proxy-multi.t

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,3 +653,36 @@ qr/6data: \[DONE\]\n\n/
653653
--- error_code: 400
654654
--- response_body eval
655655
qr/.invalid endpoint.*/
656+
657+
658+
659+
=== TEST 16: schema accepts 'logging'
660+
--- config
661+
location /t {
662+
content_by_lua_block {
663+
local plugin = require("apisix.plugins.ai-proxy-multi")
664+
665+
local ok, err = plugin.check_schema({
666+
instances = {
667+
{
668+
name = "openai-1",
669+
provider = "openai",
670+
weight = 1,
671+
auth = { header = { apikey = "token" } },
672+
options = { model = "gpt-4" },
673+
},
674+
},
675+
logging = { summaries = true },
676+
})
677+
678+
if ok then
679+
ngx.say("ok")
680+
else
681+
ngx.say("bad:" .. (err or ""))
682+
end
683+
}
684+
}
685+
--- request
686+
GET /t
687+
--- response_body
688+
ok

t/plugin/ai-proxy.t

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,3 +671,30 @@ POST /embeddings
671671
--- error_code: 200
672672
--- response_body_like eval
673673
qr/.*text-embedding-ada-002*/
674+
675+
676+
677+
=== TEST 17: schema accepts 'logging'
678+
--- config
679+
location /t {
680+
content_by_lua_block {
681+
local plugin = require("apisix.plugins.ai-proxy")
682+
683+
local ok, err = plugin.check_schema({
684+
provider = "openai",
685+
auth = { header = { apikey = "token" } },
686+
options = { model = "gpt-4" },
687+
logging = { summaries = true, payloads = false },
688+
})
689+
690+
if ok then
691+
ngx.say("ok")
692+
else
693+
ngx.say("bad:" .. (err or ""))
694+
end
695+
}
696+
}
697+
--- request
698+
GET /t
699+
--- response_body
700+
ok

0 commit comments

Comments
 (0)