mirror of
https://git.sync.wtf/troed/oc-ls-stats.git
synced 2026-08-31 09:43:38 +03:00
fix: dedupe discovered server URLs
This commit is contained in:
+2
-2
@@ -271,9 +271,9 @@ export function resolveServerUrls(options: unknown, providers: unknown, config:
|
||||
if (server !== undefined) {
|
||||
console.warn("[oc-ls-stats] ignoring invalid 'server' plugin option, falling back to provider detection")
|
||||
}
|
||||
const detected = extractProviderUrlsFromList(providers)
|
||||
const detected = [...new Set(extractProviderUrlsFromList(providers))]
|
||||
if (detected.length > 0) return detected
|
||||
const legacy = extractProviderUrls(config)
|
||||
const legacy = [...new Set(extractProviderUrls(config))]
|
||||
return legacy.length > 0 ? legacy : ["http://localhost:8080"]
|
||||
}
|
||||
|
||||
|
||||
@@ -215,3 +215,11 @@ test("selectSessionUrls first match wins for duplicate ids", () => {
|
||||
]
|
||||
assert.deepEqual(selectSessionUrls(candidates, providers, "dup"), ["http://b:2"])
|
||||
})
|
||||
|
||||
test("duplicate provider URLs are deduped", () => {
|
||||
const providers = [
|
||||
{ id: "llamacpp-a", name: "A", options: { baseURL: "http://same:7" } },
|
||||
{ id: "llamacpp-b", name: "B", options: { baseURL: "http://same:7/v1" } },
|
||||
]
|
||||
assert.deepEqual(resolveServerUrls(undefined, providers, {}), ["http://same:7"])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user