mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
fix(webui): usage CSV, detail flags, burn-down labels
This commit is contained in:
@@ -752,6 +752,33 @@ describe('useSpendStore detail fallback', () => {
|
||||
expect(spend.rankingError).toBe('')
|
||||
})
|
||||
|
||||
it('falls back on a 400 for a range not on the known-rejected list (day/14)', async () => {
|
||||
const urls: string[] = []
|
||||
mockedAdminFetch.mockImplementation((async (path: string) => {
|
||||
urls.push(path)
|
||||
if (path.includes('detail=1')) throw tooLarge()
|
||||
return { ...rankingWith(['a/one']), detail: false, models: [{ id: 'a/one', value: 5 }] }
|
||||
}) as typeof adminFetch)
|
||||
useFiltersStore().setFilters({ range: '14d' })
|
||||
const spend = useSpendStore()
|
||||
await spend.fetchModelRanking()
|
||||
expect(urls).toHaveLength(2)
|
||||
expect(spend.detailAvailable).toBe(false)
|
||||
expect(spend.rankingError).toBe('')
|
||||
})
|
||||
|
||||
it('keeps the two ranking flags independent', async () => {
|
||||
mockedAdminFetch.mockImplementation((async (path: string) => {
|
||||
if (path.includes('metric=req') && path.includes('detail=1')) throw tooLarge()
|
||||
return { ...rankingWith(['a/one']), models: [{ id: 'a/one', value: 5 }] }
|
||||
}) as typeof adminFetch)
|
||||
const spend = useSpendStore()
|
||||
await spend.fetchModelRanking()
|
||||
await spend.fetchPricingHealthRanking()
|
||||
expect(spend.pricingDetailAvailable).toBe(false)
|
||||
expect(spend.detailAvailable).toBe(true)
|
||||
})
|
||||
|
||||
it('does the same for the pricing-health ranking', async () => {
|
||||
mockedAdminFetch.mockImplementation((async (path: string) => {
|
||||
if (path.includes('detail=1')) throw tooLarge()
|
||||
@@ -761,7 +788,7 @@ describe('useSpendStore detail fallback', () => {
|
||||
await spend.fetchPricingHealthRanking()
|
||||
expect(spend.pricingHealthRanking).toHaveLength(1)
|
||||
expect(spend.pricingHealthError).toBe('')
|
||||
expect(spend.detailAvailable).toBe(false)
|
||||
expect(spend.pricingDetailAvailable).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps surfacing non-400 failures', async () => {
|
||||
|
||||
@@ -130,8 +130,10 @@ export const useSpendStore = defineStore('spend', {
|
||||
* longer discards a row specifically BECAUSE it is unpriced.
|
||||
*/
|
||||
pricingHealthRanking: [] as AdminUsageModelsResponse['models'],
|
||||
/** False when the server refused `detail=1` for this range (400 range too large) and the rankings fell back to value-only rows, so per-model tokens, cost and free flags are absent. */
|
||||
/** False when the server refused `detail=1` for this range (400 range too large) and the model ranking fell back to value-only rows, so per-model tokens, cost and free flags are absent. */
|
||||
detailAvailable: true,
|
||||
/** Same as detailAvailable, for the pricing-health ranking. */
|
||||
pricingDetailAvailable: true,
|
||||
|
||||
// --- burn-down (BurnDownChart) ---
|
||||
burndownBuckets: [] as string[],
|
||||
@@ -348,7 +350,7 @@ export const useSpendStore = defineStore('spend', {
|
||||
const { res, detail } = await fetchModelsRanking('req', filters.window, filters.span)
|
||||
if (requestId !== this.pricingHealthReqId) return
|
||||
this.pricingHealthRanking = res.models
|
||||
this.detailAvailable = detail
|
||||
this.pricingDetailAvailable = detail
|
||||
this.pricingHealthError = ''
|
||||
this.pricingHealthLoaded = true
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user