mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
chore(plugin): exercise the decision block in catalog testData
The auto router gets a shadow decision block and a provider with a decision path prefix. The manifest test mirrors both and runs New() on them.
This commit is contained in:
+12
-2
@@ -12,7 +12,7 @@ import: github.com/lukaszraczylo/traefik-llmgateway
|
|||||||
# integration suite). Required for both Traefik itself and the Plugin
|
# integration suite). Required for both Traefik itself and the Plugin
|
||||||
# Catalog analyzer (piceus), which uses this identical mechanism.
|
# Catalog analyzer (piceus), which uses this identical mechanism.
|
||||||
basePkg: traefikllmgateway
|
basePkg: traefikllmgateway
|
||||||
summary: Multi-provider LLM gateway with groups, per-user keys, token/cost limits, MCP/A2A proxy.
|
summary: Multi-provider LLM gateway with groups, per-user keys, token/cost limits, smart routers, MCP/A2A proxy.
|
||||||
testData:
|
testData:
|
||||||
providers:
|
providers:
|
||||||
openai:
|
openai:
|
||||||
@@ -21,6 +21,13 @@ testData:
|
|||||||
models:
|
models:
|
||||||
- gpt-test
|
- gpt-test
|
||||||
- gpt-test-large
|
- gpt-test-large
|
||||||
|
decider:
|
||||||
|
type: openai
|
||||||
|
apiKey: test-key
|
||||||
|
models:
|
||||||
|
- decider-test
|
||||||
|
pathBaseUrls:
|
||||||
|
/v1/decide: http://decider.example.invalid
|
||||||
groups:
|
groups:
|
||||||
default:
|
default:
|
||||||
providers: []
|
providers: []
|
||||||
@@ -36,7 +43,7 @@ testData:
|
|||||||
# copy-pasted example here would risk skipping past.
|
# copy-pasted example here would risk skipping past.
|
||||||
metrics:
|
metrics:
|
||||||
enabled: true
|
enabled: true
|
||||||
# Two-tier smart router with the v2 classifier, see README.md#smart-routers.
|
# Two-tier smart router with the v2 classifier and a shadow decision model, see README.md#smart-routers.
|
||||||
smartRouters:
|
smartRouters:
|
||||||
auto:
|
auto:
|
||||||
classifier: v2
|
classifier: v2
|
||||||
@@ -47,3 +54,6 @@ testData:
|
|||||||
- name: large
|
- name: large
|
||||||
minScore: 400
|
minScore: 400
|
||||||
models: [openai/gpt-test-large]
|
models: [openai/gpt-test-large]
|
||||||
|
decision:
|
||||||
|
provider: decider
|
||||||
|
mode: shadow
|
||||||
|
|||||||
+8
-2
@@ -35,6 +35,8 @@ func testDataConfig(t *testing.T) *Config {
|
|||||||
"openai", "type: openai", "test-key", "gpt-test", "gpt-test-large", // providers.openai
|
"openai", "type: openai", "test-key", "gpt-test", "gpt-test-large", // providers.openai
|
||||||
"auto", "classifier: v2", "name: small", "name: large", "minScore: 400", // smartRouters.auto
|
"auto", "classifier: v2", "name: small", "name: large", "minScore: 400", // smartRouters.auto
|
||||||
"[openai/gpt-test]", "[openai/gpt-test-large]", // smartRouters.auto tier models
|
"[openai/gpt-test]", "[openai/gpt-test-large]", // smartRouters.auto tier models
|
||||||
|
"decider", "decider-test", "pathBaseUrls", "/v1/decide: http://decider.example.invalid", // providers.decider
|
||||||
|
"decision:", "provider: decider", "mode: shadow", // smartRouters.auto.decision
|
||||||
"default", // groups.default and users.inline[0].group
|
"default", // groups.default and users.inline[0].group
|
||||||
"providers: []", // groups.default.providers — zero-semantic hedge, not bare {}
|
"providers: []", // groups.default.providers — zero-semantic hedge, not bare {}
|
||||||
"tester", // users.inline[0].name
|
"tester", // users.inline[0].name
|
||||||
@@ -52,8 +54,9 @@ func testDataConfig(t *testing.T) *Config {
|
|||||||
|
|
||||||
cfg := CreateConfig()
|
cfg := CreateConfig()
|
||||||
// mirror of testData, kept in sync by this test living next to the manifest
|
// mirror of testData, kept in sync by this test living next to the manifest
|
||||||
blob := `{"providers":{"openai":{"type":"openai","apiKey":"test-key","models":["gpt-test","gpt-test-large"]}},
|
blob := `{"providers":{"openai":{"type":"openai","apiKey":"test-key","models":["gpt-test","gpt-test-large"]},
|
||||||
"smartRouters":{"auto":{"classifier":"v2","tiers":[
|
"decider":{"type":"openai","apiKey":"test-key","models":["decider-test"],"pathBaseUrls":{"/v1/decide":"http://decider.example.invalid"}}},
|
||||||
|
"smartRouters":{"auto":{"classifier":"v2","decision":{"provider":"decider","mode":"shadow"},"tiers":[
|
||||||
{"name":"small","minScore":0,"models":["openai/gpt-test"]},
|
{"name":"small","minScore":0,"models":["openai/gpt-test"]},
|
||||||
{"name":"large","minScore":400,"models":["openai/gpt-test-large"]}]}},
|
{"name":"large","minScore":400,"models":["openai/gpt-test-large"]}]}},
|
||||||
"groups":{"default":{"providers":[]}},
|
"groups":{"default":{"providers":[]}},
|
||||||
@@ -70,6 +73,9 @@ func TestNewFromTestData(t *testing.T) {
|
|||||||
if router := cfg.SmartRouters["auto"]; router == nil || len(router.Tiers) != 2 {
|
if router := cfg.SmartRouters["auto"]; router == nil || len(router.Tiers) != 2 {
|
||||||
t.Fatalf("testData must declare the two-tier smart router %q, got %+v", "auto", router)
|
t.Fatalf("testData must declare the two-tier smart router %q, got %+v", "auto", router)
|
||||||
}
|
}
|
||||||
|
if d := cfg.SmartRouters["auto"].Decision; d == nil || d.Provider != "decider" {
|
||||||
|
t.Fatalf("testData must declare the decision block, got %+v", d)
|
||||||
|
}
|
||||||
h, err := New(context.Background(), next, cfg, "llmgw")
|
h, err := New(context.Background(), next, cfg, "llmgw")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("New: %v", err)
|
t.Fatalf("New: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user