mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
Add usage metadata frontend plumbing
This commit is contained in:
@@ -61,11 +61,17 @@ export interface UsageRecordDetail {
|
|||||||
cost: number // 官方费率
|
cost: number // 官方费率
|
||||||
actual_cost?: number // 倍率消耗(仅管理员可见)
|
actual_cost?: number // 倍率消耗(仅管理员可见)
|
||||||
rate_multiplier?: number // 成本倍率(仅管理员可见)
|
rate_multiplier?: number // 成本倍率(仅管理员可见)
|
||||||
response_time_ms?: number
|
response_time_ms?: number | null
|
||||||
|
first_byte_time_ms?: number | null
|
||||||
is_stream: boolean
|
is_stream: boolean
|
||||||
upstream_is_stream?: boolean
|
upstream_is_stream?: boolean
|
||||||
client_requested_stream?: boolean
|
client_requested_stream?: boolean
|
||||||
client_is_stream?: boolean
|
client_is_stream?: boolean
|
||||||
|
client_family?: string | null
|
||||||
|
client_ip?: string | null
|
||||||
|
user_agent?: string | null
|
||||||
|
request_path?: string | null
|
||||||
|
request_path_and_query?: string | null
|
||||||
created_at: string
|
created_at: string
|
||||||
cache_creation_input_tokens?: number
|
cache_creation_input_tokens?: number
|
||||||
cache_creation_ephemeral_5m_input_tokens?: number
|
cache_creation_ephemeral_5m_input_tokens?: number
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ export interface UsageRecord {
|
|||||||
response_time?: number
|
response_time?: number
|
||||||
created_at: string
|
created_at: string
|
||||||
has_fallback?: boolean // 🆕 是否发生了 fallback
|
has_fallback?: boolean // 🆕 是否发生了 fallback
|
||||||
|
client_family?: string | null
|
||||||
|
client_ip?: string | null
|
||||||
|
user_agent?: string | null
|
||||||
|
request_path?: string | null
|
||||||
|
request_path_and_query?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UsageStats {
|
export interface UsageStats {
|
||||||
@@ -106,6 +111,7 @@ export interface UsageFilters {
|
|||||||
granularity?: 'hour' | 'day' | 'week' | 'month'
|
granularity?: 'hour' | 'day' | 'week' | 'month'
|
||||||
timezone?: string
|
timezone?: string
|
||||||
tz_offset_minutes?: number
|
tz_offset_minutes?: number
|
||||||
|
client_family?: string
|
||||||
page?: number
|
page?: number
|
||||||
page_size?: number
|
page_size?: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export interface FilterParams {
|
|||||||
provider?: string
|
provider?: string
|
||||||
api_format?: string
|
api_format?: string
|
||||||
status?: string
|
status?: string
|
||||||
|
client_family?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUsageProviderVisible(provider: string | undefined | null): provider is string {
|
function isUsageProviderVisible(provider: string | undefined | null): provider is string {
|
||||||
@@ -371,6 +372,9 @@ export function useUsageData(options: UseUsageDataOptions) {
|
|||||||
if (filters?.status) {
|
if (filters?.status) {
|
||||||
params.status = filters.status
|
params.status = filters.status
|
||||||
}
|
}
|
||||||
|
if (filters?.client_family) {
|
||||||
|
params.client_family = filters.client_family
|
||||||
|
}
|
||||||
|
|
||||||
const response = await usageApi.getAllUsageRecords(params)
|
const response = await usageApi.getAllUsageRecords(params)
|
||||||
if (requestId !== loadRecordsRequestId) {
|
if (requestId !== loadRecordsRequestId) {
|
||||||
|
|||||||
@@ -106,12 +106,17 @@ export interface UsageRecord {
|
|||||||
total_tokens: number
|
total_tokens: number
|
||||||
cost: number
|
cost: number
|
||||||
actual_cost?: number
|
actual_cost?: number
|
||||||
response_time_ms?: number
|
response_time_ms?: number | null
|
||||||
first_byte_time_ms?: number // 首字时间 (TTFB)
|
first_byte_time_ms?: number | null // 首字时间 (TTFB)
|
||||||
is_stream: boolean
|
is_stream: boolean
|
||||||
upstream_is_stream?: boolean
|
upstream_is_stream?: boolean
|
||||||
client_requested_stream?: boolean
|
client_requested_stream?: boolean
|
||||||
client_is_stream?: boolean
|
client_is_stream?: boolean
|
||||||
|
client_family?: string | null
|
||||||
|
client_ip?: string | null
|
||||||
|
user_agent?: string | null
|
||||||
|
request_path?: string | null
|
||||||
|
request_path_and_query?: string | null
|
||||||
status_code?: number
|
status_code?: number
|
||||||
error_message?: string
|
error_message?: string
|
||||||
status?: RequestStatus // 请求状态: pending, streaming, completed, failed
|
status?: RequestStatus // 请求状态: pending, streaming, completed, failed
|
||||||
@@ -142,7 +147,8 @@ export type FilterStatusValue =
|
|||||||
'active' |
|
'active' |
|
||||||
'failed' |
|
'failed' |
|
||||||
'cancelled' |
|
'cancelled' |
|
||||||
'has_fallback'
|
'has_fallback' |
|
||||||
|
'has_retry'
|
||||||
|
|
||||||
// 默认统计状态
|
// 默认统计状态
|
||||||
export function createDefaultStats(): UsageStatsState {
|
export function createDefaultStats(): UsageStatsState {
|
||||||
|
|||||||
Reference in New Issue
Block a user