mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-10-15 05:29:28 +00:00
feat(admin,webui): metadata exposure
admin.go: adminProviderView gains ModelMeta (map[string]adminModelMetaView,
keyed by upstream model id) and adminAliasView gains its own ModelMeta —
both built via g.registry.resolveMetaFor/resolveMetaForAliasName
(feature v0.23). adminModelMetaView uses pointer fields
(*int/*float64), not plain zero values: a nil pointer means unknown, a
non-nil pointer (even one pointing at 0) means known, so a free model's
real zero cost never gets confused with an absent one over JSON.
resolveMetaForAliasName resolves an alias's metadata for this
unrestricted admin view via an internal &group{} (GroupConfig's own
documented empty-means-all semantics) — buildAdminOverview already
shows every provider/alias unconditionally, with no group filtering
anywhere else in its response either.
webui/src/types/api.ts: AdminModelMetaView mirrors the Go shape
(optional numbers, undefined means unknown); AdminProviderView.modelMeta
and AdminAliasView.modelMeta wire it through.
webui/src/lib/format.ts: formatContextWindow (binary-K "256k"-style),
formatModelCostHover ("in $X / out $Y per MTok", or "free"), and
their shared formatUsdPerMTok building block.
ModelChip.vue (operator scope refinement): every chip — the accordion's
model chips, the alias table's chips, a group's usage-detail chips —
gains optional contextTokens/inputPerMTokUsd/outputPerMTokUsd props.
When known, they append a resolved-metadata phrase to the existing
copy-state hover text, bound to BOTH title and aria-label (the same
mouse-vs-keyboard/screen-reader parity ProviderRateBadge.vue already
applies); when nothing is known, the hover is unchanged from before this
feature. An alias's chip carries its INHERITED metadata, matching the
alias-inheritance rule the backend already applies.
ProvidersView.vue: the accordion's model list gains a visible, muted
context-only chip ("256k") beside each ModelChip — cost stays
hover-only on the chip itself, per the operator's own "chips +
hover would be redundant on price" resolution.
This commit is contained in:
@@ -27,6 +27,19 @@ export interface AdminModelRateView {
|
||||
failuresDay: number
|
||||
}
|
||||
|
||||
/**
|
||||
* One upstream model's resolved metadata (admin.go: adminModelMetaView —
|
||||
* feature v0.23: context window, per-token cost). Every field is
|
||||
* optional/undefined, not a plain 0 — undefined means "unknown", any
|
||||
* present value (including 0, a free model's real cost) means "known".
|
||||
* Never infer "unknown" from a value being falsy; check for undefined.
|
||||
*/
|
||||
export interface AdminModelMetaView {
|
||||
contextTokens?: number
|
||||
inputPerMTokUsd?: number
|
||||
outputPerMTokUsd?: number
|
||||
}
|
||||
|
||||
export interface AdminProviderView {
|
||||
name: string
|
||||
type: string
|
||||
@@ -36,6 +49,13 @@ export interface AdminProviderView {
|
||||
/** Sorted explicit∪discovered model ids (admin.go: adminProviderView.Models) — always an array, never omitted, even when empty. */
|
||||
models: string[]
|
||||
modelCount: number
|
||||
/**
|
||||
* Resolved metadata (context window, per-token cost — feature v0.23)
|
||||
* for every id in `models`, keyed by upstream model id. Always
|
||||
* present (possibly with every sub-field undefined), never omitted —
|
||||
* mirroring modelRates' own "never nil" convention below.
|
||||
*/
|
||||
modelMeta: Record<string, AdminModelMetaView>
|
||||
/**
|
||||
* discoveryEnabled mirrors the provider's own configured Discovery flag
|
||||
* (admin.go: adminProviderView.DiscoveryEnabled — Feature B, v0.22): the
|
||||
@@ -85,6 +105,13 @@ export interface AdminGroupView {
|
||||
export interface AdminAliasView {
|
||||
alias: string
|
||||
target: string
|
||||
/**
|
||||
* The alias's own resolved metadata (admin.go: adminAliasView.
|
||||
* ModelMeta — feature v0.23): INHERITED from its target unless the
|
||||
* alias itself carries its own modelMeta override. Always present
|
||||
* (possibly with every sub-field undefined).
|
||||
*/
|
||||
modelMeta: AdminModelMetaView
|
||||
}
|
||||
|
||||
/** GET /admin/api/overview (admin.go: adminOverviewResponse). */
|
||||
|
||||
Reference in New Issue
Block a user