feat: 使用量轮询接口添加 API 格式转换字段

- 前端:添加 api_format、endpoint_api_format、has_format_conversion 类型定义
- 前端:轮询时同步更新格式转换相关字段
- 后端:查询时返回格式转换字段,包含历史数据兼容逻辑
- 后端:优化 import 位置提升性能
This commit is contained in:
fawney19
2026-01-28 11:24:37 +08:00
parent 5c80be92c9
commit bd843bca61
4 changed files with 33 additions and 0 deletions

View File

@@ -223,6 +223,9 @@ export const meApi = {
rate_multiplier?: number | null
response_time_ms: number | null
first_byte_time_ms: number | null
api_format?: string | null
endpoint_api_format?: string | null
has_format_conversion?: boolean | null
}>
}> {
const params = ids ? { ids } : {}

View File

@@ -201,6 +201,9 @@ export const usageApi = {
first_byte_time_ms: number | null
provider?: string | null
api_key_name?: string | null
api_format?: string | null
endpoint_api_format?: string | null
has_format_conversion?: boolean | null
}>
}> {
const params = ids?.length ? { ids: ids.join(',') } : {}

View File

@@ -290,6 +290,10 @@ async function pollActiveRequests() {
record.rate_multiplier = update.rate_multiplier ?? undefined
record.response_time_ms = update.response_time_ms ?? undefined
record.first_byte_time_ms = update.first_byte_time_ms ?? undefined
// API 格式/格式转换streaming 时已可确定,轮询时同步更新
if (update.api_format !== undefined) record.api_format = update.api_format
if (update.endpoint_api_format !== undefined) record.endpoint_api_format = update.endpoint_api_format
if (update.has_format_conversion !== undefined) record.has_format_conversion = update.has_format_conversion
// 管理员接口返回额外字段
if ('provider' in update && typeof update.provider === 'string') {
record.provider = update.provider