mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-12-06 11:03:52 +00:00
feat: admin redesign, decision assist, prompt caching and shared state (#11)
This change adds the redesigned admin panel and the smart router decision model assist. It adds opt-in prompt-prefix caching per provider and cached-token pricing and metrics. With Redis, the metrics route reports fleet-wide values. The redis.sharedState switch shares six coordination states across replicas. PR CI grants actions read, which the shared go-pr workflow needs. The pull request description has the full list and the verification.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
export const LIMIT: number
|
||||
export const DIST: string
|
||||
export function hasDist(): boolean
|
||||
export function measure(dir?: string): { file: string; gzip: number }[]
|
||||
export function totalGzip(dir?: string): number
|
||||
export function readCss(dir?: string): string
|
||||
@@ -0,0 +1,39 @@
|
||||
// Gate scope: gzip (level 9) of every .js and .css in dist/assets, lazy chunks included.
|
||||
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { gzipSync } from 'node:zlib'
|
||||
|
||||
export const LIMIT = 324300
|
||||
export const DIST = fileURLToPath(new URL('../dist/assets', import.meta.url))
|
||||
|
||||
export const hasDist = () => existsSync(DIST)
|
||||
|
||||
export function readCss(dir = DIST) {
|
||||
return readdirSync(dir)
|
||||
.filter((f) => f.endsWith('.css'))
|
||||
.map((f) => readFileSync(join(dir, f), 'utf8'))
|
||||
.join('\n')
|
||||
}
|
||||
|
||||
export function totalGzip(dir = DIST) {
|
||||
return measure(dir).reduce((n, r) => n + r.gzip, 0)
|
||||
}
|
||||
|
||||
export function measure(dir = DIST) {
|
||||
return readdirSync(dir)
|
||||
.filter((f) => /\.(js|css)$/.test(f))
|
||||
.map((f) => ({ file: f, gzip: gzipSync(readFileSync(join(dir, f)), { level: 9 }).length }))
|
||||
.sort((a, b) => b.gzip - a.gzip)
|
||||
}
|
||||
|
||||
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||
const rows = measure()
|
||||
const total = totalGzip()
|
||||
for (const r of rows.slice(0, 10)) console.log(`${String(r.gzip).padStart(8)} ${r.file}`)
|
||||
console.log(`total gzip JS+CSS: ${total} B (limit ${LIMIT}); ${rows.length} files`)
|
||||
if (total > LIMIT) {
|
||||
console.error('bundle gate FAILED')
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user