mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-07 10:12:27 +08:00
Initial commit
This commit is contained in:
57
frontend/src/api/endpoints/adaptive.ts
Normal file
57
frontend/src/api/endpoints/adaptive.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import client from '../client'
|
||||
import type { AdaptiveStatsResponse } from './types'
|
||||
|
||||
/**
|
||||
* 启用/禁用 Key 的自适应模式
|
||||
*/
|
||||
export async function toggleAdaptiveMode(
|
||||
keyId: string,
|
||||
data: {
|
||||
enabled: boolean
|
||||
fixed_limit?: number
|
||||
}
|
||||
): Promise<{
|
||||
message: string
|
||||
key_id: string
|
||||
is_adaptive: boolean
|
||||
max_concurrent: number | null
|
||||
effective_limit: number | null
|
||||
}> {
|
||||
const response = await client.patch(`/api/admin/adaptive/keys/${keyId}/mode`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 Key 的固定并发限制
|
||||
*/
|
||||
export async function setConcurrentLimit(
|
||||
keyId: string,
|
||||
limit: number
|
||||
): Promise<{
|
||||
message: string
|
||||
key_id: string
|
||||
is_adaptive: boolean
|
||||
max_concurrent: number
|
||||
previous_mode: string
|
||||
}> {
|
||||
const response = await client.patch(`/api/admin/adaptive/keys/${keyId}/limit`, null, {
|
||||
params: { limit }
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Key 的自适应统计
|
||||
*/
|
||||
export async function getAdaptiveStats(keyId: string): Promise<AdaptiveStatsResponse> {
|
||||
const response = await client.get(`/api/admin/adaptive/keys/${keyId}/stats`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置 Key 的学习状态
|
||||
*/
|
||||
export async function resetAdaptiveLearning(keyId: string): Promise<{ message: string; key_id: string }> {
|
||||
const response = await client.delete(`/api/admin/adaptive/keys/${keyId}/learning`)
|
||||
return response.data
|
||||
}
|
||||
121
frontend/src/api/endpoints/aliases.ts
Normal file
121
frontend/src/api/endpoints/aliases.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* 模型别名管理 API
|
||||
*/
|
||||
|
||||
import client from '../client'
|
||||
import type { ModelMapping, ModelMappingCreate, ModelMappingUpdate } from './types'
|
||||
|
||||
export interface ModelAlias {
|
||||
id: string
|
||||
alias: string
|
||||
global_model_id: string
|
||||
global_model_name: string | null
|
||||
global_model_display_name: string | null
|
||||
provider_id: string | null
|
||||
provider_name: string | null
|
||||
scope: 'global' | 'provider'
|
||||
mapping_type: 'alias' | 'mapping'
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface CreateModelAliasRequest {
|
||||
alias: string
|
||||
global_model_id: string
|
||||
provider_id?: string | null
|
||||
mapping_type?: 'alias' | 'mapping'
|
||||
is_active?: boolean
|
||||
}
|
||||
|
||||
export interface UpdateModelAliasRequest {
|
||||
alias?: string
|
||||
global_model_id?: string
|
||||
provider_id?: string | null
|
||||
mapping_type?: 'alias' | 'mapping'
|
||||
is_active?: boolean
|
||||
}
|
||||
|
||||
function transformMapping(mapping: ModelMapping): ModelAlias {
|
||||
return {
|
||||
id: mapping.id,
|
||||
alias: mapping.source_model,
|
||||
global_model_id: mapping.target_global_model_id,
|
||||
global_model_name: mapping.target_global_model_name,
|
||||
global_model_display_name: mapping.target_global_model_display_name,
|
||||
provider_id: mapping.provider_id ?? null,
|
||||
provider_name: mapping.provider_name ?? null,
|
||||
scope: mapping.scope,
|
||||
mapping_type: mapping.mapping_type || 'alias',
|
||||
is_active: mapping.is_active,
|
||||
created_at: mapping.created_at,
|
||||
updated_at: mapping.updated_at
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取别名列表
|
||||
*/
|
||||
export async function getAliases(params?: {
|
||||
provider_id?: string
|
||||
global_model_id?: string
|
||||
is_active?: boolean
|
||||
skip?: number
|
||||
limit?: number
|
||||
}): Promise<ModelAlias[]> {
|
||||
const response = await client.get('/api/admin/models/mappings', {
|
||||
params: {
|
||||
provider_id: params?.provider_id,
|
||||
target_global_model_id: params?.global_model_id,
|
||||
is_active: params?.is_active,
|
||||
skip: params?.skip,
|
||||
limit: params?.limit
|
||||
}
|
||||
})
|
||||
return (response.data as ModelMapping[]).map(transformMapping)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个别名
|
||||
*/
|
||||
export async function getAlias(id: string): Promise<ModelAlias> {
|
||||
const response = await client.get(`/api/admin/models/mappings/${id}`)
|
||||
return transformMapping(response.data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建别名
|
||||
*/
|
||||
export async function createAlias(data: CreateModelAliasRequest): Promise<ModelAlias> {
|
||||
const payload: ModelMappingCreate = {
|
||||
source_model: data.alias,
|
||||
target_global_model_id: data.global_model_id,
|
||||
provider_id: data.provider_id ?? null,
|
||||
mapping_type: data.mapping_type ?? 'alias',
|
||||
is_active: data.is_active ?? true
|
||||
}
|
||||
const response = await client.post('/api/admin/models/mappings', payload)
|
||||
return transformMapping(response.data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新别名
|
||||
*/
|
||||
export async function updateAlias(id: string, data: UpdateModelAliasRequest): Promise<ModelAlias> {
|
||||
const payload: ModelMappingUpdate = {
|
||||
source_model: data.alias,
|
||||
target_global_model_id: data.global_model_id,
|
||||
provider_id: data.provider_id ?? null,
|
||||
mapping_type: data.mapping_type,
|
||||
is_active: data.is_active
|
||||
}
|
||||
const response = await client.patch(`/api/admin/models/mappings/${id}`, payload)
|
||||
return transformMapping(response.data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除别名
|
||||
*/
|
||||
export async function deleteAlias(id: string): Promise<void> {
|
||||
await client.delete(`/api/admin/models/mappings/${id}`)
|
||||
}
|
||||
78
frontend/src/api/endpoints/endpoints.ts
Normal file
78
frontend/src/api/endpoints/endpoints.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import client from '../client'
|
||||
import type { ProviderEndpoint } from './types'
|
||||
|
||||
/**
|
||||
* 获取指定 Provider 的所有 Endpoints
|
||||
*/
|
||||
export async function getProviderEndpoints(providerId: string): Promise<ProviderEndpoint[]> {
|
||||
const response = await client.get(`/api/admin/endpoints/providers/${providerId}/endpoints`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Endpoint 详情
|
||||
*/
|
||||
export async function getEndpoint(endpointId: string): Promise<ProviderEndpoint> {
|
||||
const response = await client.get(`/api/admin/endpoints/${endpointId}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 Provider 创建新的 Endpoint
|
||||
*/
|
||||
export async function createEndpoint(
|
||||
providerId: string,
|
||||
data: {
|
||||
provider_id: string
|
||||
api_format: string
|
||||
base_url: string
|
||||
custom_path?: string
|
||||
auth_type?: string
|
||||
auth_header?: string
|
||||
headers?: Record<string, string>
|
||||
timeout?: number
|
||||
max_retries?: number
|
||||
priority?: number
|
||||
weight?: number
|
||||
max_concurrent?: number
|
||||
rate_limit?: number
|
||||
is_active?: boolean
|
||||
config?: Record<string, any>
|
||||
}
|
||||
): Promise<ProviderEndpoint> {
|
||||
const response = await client.post(`/api/admin/endpoints/providers/${providerId}/endpoints`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 Endpoint
|
||||
*/
|
||||
export async function updateEndpoint(
|
||||
endpointId: string,
|
||||
data: Partial<{
|
||||
base_url: string
|
||||
custom_path: string
|
||||
auth_type: string
|
||||
auth_header: string
|
||||
headers: Record<string, string>
|
||||
timeout: number
|
||||
max_retries: number
|
||||
priority: number
|
||||
weight: number
|
||||
max_concurrent: number
|
||||
rate_limit: number
|
||||
is_active: boolean
|
||||
config: Record<string, any>
|
||||
}>
|
||||
): Promise<ProviderEndpoint> {
|
||||
const response = await client.put(`/api/admin/endpoints/${endpointId}`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 Endpoint
|
||||
*/
|
||||
export async function deleteEndpoint(endpointId: string): Promise<{ message: string; deleted_keys_count: number }> {
|
||||
const response = await client.delete(`/api/admin/endpoints/${endpointId}`)
|
||||
return response.data
|
||||
}
|
||||
85
frontend/src/api/endpoints/global-models.ts
Normal file
85
frontend/src/api/endpoints/global-models.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import client from '../client'
|
||||
import type {
|
||||
GlobalModelCreate,
|
||||
GlobalModelUpdate,
|
||||
GlobalModelResponse,
|
||||
GlobalModelWithStats,
|
||||
GlobalModelListResponse
|
||||
} from './types'
|
||||
|
||||
/**
|
||||
* 获取 GlobalModel 列表
|
||||
*/
|
||||
export async function getGlobalModels(params?: {
|
||||
skip?: number
|
||||
limit?: number
|
||||
is_active?: boolean
|
||||
search?: string
|
||||
}): Promise<GlobalModelListResponse> {
|
||||
const response = await client.get('/api/admin/models/global', { params })
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个 GlobalModel 详情
|
||||
*/
|
||||
export async function getGlobalModel(id: string): Promise<GlobalModelWithStats> {
|
||||
const response = await client.get(`/api/admin/models/global/${id}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 GlobalModel
|
||||
*/
|
||||
export async function createGlobalModel(data: GlobalModelCreate): Promise<GlobalModelResponse> {
|
||||
const response = await client.post('/api/admin/models/global', data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 GlobalModel
|
||||
*/
|
||||
export async function updateGlobalModel(
|
||||
id: string,
|
||||
data: GlobalModelUpdate
|
||||
): Promise<GlobalModelResponse> {
|
||||
const response = await client.patch(`/api/admin/models/global/${id}`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 GlobalModel
|
||||
*/
|
||||
export async function deleteGlobalModel(
|
||||
id: string,
|
||||
force: boolean = false
|
||||
): Promise<void> {
|
||||
await client.delete(`/api/admin/models/global/${id}`, { params: { force } })
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量为 GlobalModel 添加关联提供商
|
||||
*/
|
||||
export async function batchAssignToProviders(
|
||||
globalModelId: string,
|
||||
data: {
|
||||
provider_ids: string[]
|
||||
create_models: boolean
|
||||
}
|
||||
): Promise<{
|
||||
success: Array<{
|
||||
provider_id: string
|
||||
provider_name: string
|
||||
model_id?: string
|
||||
}>
|
||||
errors: Array<{
|
||||
provider_id: string
|
||||
error: string
|
||||
}>
|
||||
}> {
|
||||
const response = await client.post(
|
||||
`/api/admin/models/global/${globalModelId}/assign-to-providers`,
|
||||
data
|
||||
)
|
||||
return response.data
|
||||
}
|
||||
88
frontend/src/api/endpoints/health.ts
Normal file
88
frontend/src/api/endpoints/health.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import client from '../client'
|
||||
import type {
|
||||
HealthStatus,
|
||||
HealthSummary,
|
||||
EndpointStatusMonitorResponse,
|
||||
PublicEndpointStatusMonitorResponse
|
||||
} from './types'
|
||||
|
||||
/**
|
||||
* 获取健康状态摘要
|
||||
*/
|
||||
export async function getHealthSummary(): Promise<HealthSummary> {
|
||||
const response = await client.get('/api/admin/endpoints/health/summary')
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Endpoint 健康状态
|
||||
*/
|
||||
export async function getEndpointHealth(endpointId: string): Promise<HealthStatus> {
|
||||
const response = await client.get(`/api/admin/endpoints/health/endpoint/${endpointId}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Key 健康状态
|
||||
*/
|
||||
export async function getKeyHealth(keyId: string): Promise<HealthStatus> {
|
||||
const response = await client.get(`/api/admin/endpoints/health/key/${keyId}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复Key健康状态(一键恢复:重置健康度 + 关闭熔断器 + 取消自动禁用)
|
||||
*/
|
||||
export async function recoverKeyHealth(keyId: string): Promise<{
|
||||
message: string
|
||||
details: {
|
||||
health_score: number
|
||||
circuit_breaker_open: boolean
|
||||
is_active: boolean
|
||||
}
|
||||
}> {
|
||||
const response = await client.patch(`/api/admin/endpoints/health/keys/${keyId}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量恢复所有熔断的Key健康状态
|
||||
*/
|
||||
export async function recoverAllKeysHealth(): Promise<{
|
||||
message: string
|
||||
recovered_count: number
|
||||
recovered_keys: Array<{
|
||||
key_id: string
|
||||
key_name: string
|
||||
endpoint_id: string
|
||||
}>
|
||||
}> {
|
||||
const response = await client.patch('/api/admin/endpoints/health/keys')
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取按 API 格式聚合的健康监控时间线(管理员版,含 provider/key 数量)
|
||||
*/
|
||||
export async function getEndpointStatusMonitor(params?: {
|
||||
lookback_hours?: number
|
||||
per_format_limit?: number
|
||||
}): Promise<EndpointStatusMonitorResponse> {
|
||||
const response = await client.get('/api/admin/endpoints/health/api-formats', {
|
||||
params
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取按 API 格式聚合的健康监控时间线(公开版,不含敏感信息)
|
||||
*/
|
||||
export async function getPublicEndpointStatusMonitor(params?: {
|
||||
lookback_hours?: number
|
||||
per_format_limit?: number
|
||||
}): Promise<PublicEndpointStatusMonitorResponse> {
|
||||
const response = await client.get('/api/public/health/api-formats', {
|
||||
params
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
9
frontend/src/api/endpoints/index.ts
Normal file
9
frontend/src/api/endpoints/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export * from './types'
|
||||
export * from './providers'
|
||||
export * from './endpoints'
|
||||
export * from './keys'
|
||||
export * from './health'
|
||||
export * from './models'
|
||||
export * from './aliases'
|
||||
export * from './adaptive'
|
||||
export * from './global-models'
|
||||
132
frontend/src/api/endpoints/keys.ts
Normal file
132
frontend/src/api/endpoints/keys.ts
Normal file
@@ -0,0 +1,132 @@
|
||||
import client from '../client'
|
||||
import type { EndpointAPIKey } from './types'
|
||||
|
||||
/**
|
||||
* 能力定义类型
|
||||
*/
|
||||
export interface CapabilityDefinition {
|
||||
name: string
|
||||
display_name: string
|
||||
description: string
|
||||
match_mode: 'exclusive' | 'compatible'
|
||||
config_mode?: 'user_configurable' | 'auto_detect' | 'request_param'
|
||||
short_name?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型支持的能力响应类型
|
||||
*/
|
||||
export interface ModelCapabilitiesResponse {
|
||||
model: string
|
||||
global_model_id?: string
|
||||
global_model_name?: string
|
||||
supported_capabilities: string[]
|
||||
capability_details: CapabilityDefinition[]
|
||||
error?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有能力定义
|
||||
*/
|
||||
export async function getAllCapabilities(): Promise<CapabilityDefinition[]> {
|
||||
const response = await client.get('/api/capabilities')
|
||||
return response.data.capabilities
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户可配置的能力列表
|
||||
*/
|
||||
export async function getUserConfigurableCapabilities(): Promise<CapabilityDefinition[]> {
|
||||
const response = await client.get('/api/capabilities/user-configurable')
|
||||
return response.data.capabilities
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定模型支持的能力列表
|
||||
*/
|
||||
export async function getModelCapabilities(modelName: string): Promise<ModelCapabilitiesResponse> {
|
||||
const response = await client.get(`/api/capabilities/model/${encodeURIComponent(modelName)}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Endpoint 的所有 Keys
|
||||
*/
|
||||
export async function getEndpointKeys(endpointId: string): Promise<EndpointAPIKey[]> {
|
||||
const response = await client.get(`/api/admin/endpoints/${endpointId}/keys`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 Endpoint 添加 Key
|
||||
*/
|
||||
export async function addEndpointKey(
|
||||
endpointId: string,
|
||||
data: {
|
||||
endpoint_id: string
|
||||
api_key: string
|
||||
name: string // 密钥名称(必填)
|
||||
rate_multiplier?: number // 成本倍率(默认 1.0)
|
||||
internal_priority?: number // Endpoint 内部优先级(数字越小越优先)
|
||||
max_concurrent?: number // 最大并发数(留空=自适应模式)
|
||||
rate_limit?: number
|
||||
daily_limit?: number
|
||||
monthly_limit?: number
|
||||
cache_ttl_minutes?: number // 缓存 TTL(分钟),0=禁用
|
||||
max_probe_interval_minutes?: number // 熔断探测间隔(分钟)
|
||||
allowed_models?: string[] // 允许使用的模型列表
|
||||
capabilities?: Record<string, boolean> // 能力标签配置
|
||||
note?: string // 备注说明(可选)
|
||||
}
|
||||
): Promise<EndpointAPIKey> {
|
||||
const response = await client.post(`/api/admin/endpoints/${endpointId}/keys`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 Endpoint Key
|
||||
*/
|
||||
export async function updateEndpointKey(
|
||||
keyId: string,
|
||||
data: Partial<{
|
||||
api_key: string
|
||||
name: string // 密钥名称
|
||||
rate_multiplier: number // 成本倍率
|
||||
internal_priority: number // Endpoint 内部优先级(提供商优先模式,数字越小越优先)
|
||||
global_priority: number // 全局 Key 优先级(全局 Key 优先模式,数字越小越优先)
|
||||
max_concurrent: number // 最大并发数(留空=自适应模式)
|
||||
rate_limit: number
|
||||
daily_limit: number
|
||||
monthly_limit: number
|
||||
cache_ttl_minutes: number // 缓存 TTL(分钟),0=禁用
|
||||
max_probe_interval_minutes: number // 熔断探测间隔(分钟)
|
||||
allowed_models: string[] | null // 允许使用的模型列表,null 表示允许所有
|
||||
capabilities: Record<string, boolean> | null // 能力标签配置
|
||||
is_active: boolean
|
||||
note: string // 备注说明
|
||||
}>
|
||||
): Promise<EndpointAPIKey> {
|
||||
const response = await client.put(`/api/admin/endpoints/keys/${keyId}`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 Endpoint Key
|
||||
*/
|
||||
export async function deleteEndpointKey(keyId: string): Promise<{ message: string }> {
|
||||
const response = await client.delete(`/api/admin/endpoints/keys/${keyId}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新 Endpoint Keys 的优先级(用于拖动排序)
|
||||
*/
|
||||
export async function batchUpdateKeyPriority(
|
||||
endpointId: string,
|
||||
priorities: Array<{ key_id: string; internal_priority: number }>
|
||||
): Promise<{ message: string; updated_count: number }> {
|
||||
const response = await client.put(`/api/admin/endpoints/${endpointId}/keys/batch-priority`, {
|
||||
priorities
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
145
frontend/src/api/endpoints/models.ts
Normal file
145
frontend/src/api/endpoints/models.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
import client from '../client'
|
||||
import type {
|
||||
Model,
|
||||
ModelCreate,
|
||||
ModelUpdate,
|
||||
ModelCatalogResponse,
|
||||
ProviderAvailableSourceModelsResponse,
|
||||
UpdateModelMappingRequest,
|
||||
UpdateModelMappingResponse,
|
||||
DeleteModelMappingResponse
|
||||
} from './types'
|
||||
|
||||
/**
|
||||
* 获取 Provider 的所有模型
|
||||
*/
|
||||
export async function getProviderModels(
|
||||
providerId: string,
|
||||
params?: {
|
||||
is_active?: boolean
|
||||
skip?: number
|
||||
limit?: number
|
||||
}
|
||||
): Promise<Model[]> {
|
||||
const response = await client.get(`/api/admin/providers/${providerId}/models`, { params })
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建模型
|
||||
*/
|
||||
export async function createModel(
|
||||
providerId: string,
|
||||
data: ModelCreate
|
||||
): Promise<Model> {
|
||||
const response = await client.post(`/api/admin/providers/${providerId}/models`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型详情
|
||||
*/
|
||||
export async function getModel(
|
||||
providerId: string,
|
||||
modelId: string
|
||||
): Promise<Model> {
|
||||
const response = await client.get(`/api/admin/providers/${providerId}/models/${modelId}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模型
|
||||
*/
|
||||
export async function updateModel(
|
||||
providerId: string,
|
||||
modelId: string,
|
||||
data: ModelUpdate
|
||||
): Promise<Model> {
|
||||
const response = await client.patch(`/api/admin/providers/${providerId}/models/${modelId}`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模型
|
||||
*/
|
||||
export async function deleteModel(
|
||||
providerId: string,
|
||||
modelId: string
|
||||
): Promise<{ message: string }> {
|
||||
const response = await client.delete(`/api/admin/providers/${providerId}/models/${modelId}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量创建模型
|
||||
*/
|
||||
export async function batchCreateModels(
|
||||
providerId: string,
|
||||
modelsData: ModelCreate[]
|
||||
): Promise<Model[]> {
|
||||
const response = await client.post(`/api/admin/providers/${providerId}/models/batch`, modelsData)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统一模型目录
|
||||
*/
|
||||
export async function getModelCatalog(): Promise<ModelCatalogResponse> {
|
||||
const response = await client.get('/api/admin/models/catalog')
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Provider 支持的统一模型列表
|
||||
*/
|
||||
export async function getProviderAvailableSourceModels(
|
||||
providerId: string
|
||||
): Promise<ProviderAvailableSourceModelsResponse> {
|
||||
const response = await client.get(`/api/admin/providers/${providerId}/available-source-models`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新目录中的模型映射
|
||||
*/
|
||||
export async function updateCatalogMapping(
|
||||
mappingId: string,
|
||||
data: UpdateModelMappingRequest
|
||||
): Promise<UpdateModelMappingResponse> {
|
||||
const response = await client.put(`/api/admin/models/catalog/mappings/${mappingId}`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除目录中的模型映射
|
||||
*/
|
||||
export async function deleteCatalogMapping(
|
||||
mappingId: string
|
||||
): Promise<DeleteModelMappingResponse> {
|
||||
const response = await client.delete(`/api/admin/models/catalog/mappings/${mappingId}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量为 Provider 关联 GlobalModels
|
||||
*/
|
||||
export async function batchAssignModelsToProvider(
|
||||
providerId: string,
|
||||
globalModelIds: string[]
|
||||
): Promise<{
|
||||
success: Array<{
|
||||
global_model_id: string
|
||||
global_model_name: string
|
||||
model_id: string
|
||||
}>
|
||||
errors: Array<{
|
||||
global_model_id: string
|
||||
error: string
|
||||
}>
|
||||
}> {
|
||||
const response = await client.post(
|
||||
`/api/admin/providers/${providerId}/assign-global-models`,
|
||||
{ global_model_ids: globalModelIds }
|
||||
)
|
||||
return response.data
|
||||
}
|
||||
60
frontend/src/api/endpoints/providers.ts
Normal file
60
frontend/src/api/endpoints/providers.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import client from '../client'
|
||||
import type { ProviderWithEndpointsSummary } from './types'
|
||||
|
||||
/**
|
||||
* 获取 Providers 摘要(包含 Endpoints 统计)
|
||||
*/
|
||||
export async function getProvidersSummary(): Promise<ProviderWithEndpointsSummary[]> {
|
||||
const response = await client.get('/api/admin/providers/summary')
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个 Provider 的详细信息
|
||||
*/
|
||||
export async function getProvider(providerId: string): Promise<ProviderWithEndpointsSummary> {
|
||||
const response = await client.get(`/api/admin/providers/${providerId}/summary`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 Provider 基础配置
|
||||
*/
|
||||
export async function updateProvider(
|
||||
providerId: string,
|
||||
data: Partial<{
|
||||
display_name: string
|
||||
description: string
|
||||
website: string
|
||||
provider_priority: number
|
||||
billing_type: 'monthly_quota' | 'pay_as_you_go' | 'free_tier'
|
||||
monthly_quota_usd: number
|
||||
quota_reset_day: number
|
||||
quota_last_reset_at: string // 周期开始时间
|
||||
quota_expires_at: string
|
||||
rpm_limit: number | null
|
||||
cache_ttl_minutes: number // 0表示不支持缓存,>0表示支持缓存并设置TTL(分钟)
|
||||
max_probe_interval_minutes: number
|
||||
is_active: boolean
|
||||
}>
|
||||
): Promise<ProviderWithEndpointsSummary> {
|
||||
const response = await client.patch(`/api/admin/providers/${providerId}`, data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 Provider
|
||||
*/
|
||||
export async function createProvider(data: any): Promise<any> {
|
||||
const response = await client.post('/api/admin/providers/', data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 Provider
|
||||
*/
|
||||
export async function deleteProvider(providerId: string): Promise<{ message: string }> {
|
||||
const response = await client.delete(`/api/admin/providers/${providerId}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
553
frontend/src/api/endpoints/types.ts
Normal file
553
frontend/src/api/endpoints/types.ts
Normal file
@@ -0,0 +1,553 @@
|
||||
export interface ProviderEndpoint {
|
||||
id: string
|
||||
provider_id: string
|
||||
provider_name: string
|
||||
api_format: string
|
||||
base_url: string
|
||||
custom_path?: string // 自定义请求路径(可选,为空则使用 API 格式默认路径)
|
||||
auth_type: string
|
||||
auth_header?: string
|
||||
headers?: Record<string, string>
|
||||
timeout: number
|
||||
max_retries: number
|
||||
priority: number
|
||||
weight: number
|
||||
max_concurrent?: number
|
||||
rate_limit?: number
|
||||
health_score: number
|
||||
consecutive_failures: number
|
||||
last_failure_at?: string
|
||||
is_active: boolean
|
||||
config?: Record<string, any>
|
||||
total_keys: number
|
||||
active_keys: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface EndpointAPIKey {
|
||||
id: string
|
||||
endpoint_id: string
|
||||
api_key_masked: string
|
||||
api_key_plain?: string | null
|
||||
name: string // 密钥名称(必填,用于识别)
|
||||
rate_multiplier: number // 成本倍率(真实成本 = 表面成本 × 倍率)
|
||||
internal_priority: number // Endpoint 内部优先级
|
||||
global_priority?: number | null // 全局 Key 优先级
|
||||
max_concurrent?: number
|
||||
rate_limit?: number
|
||||
daily_limit?: number
|
||||
monthly_limit?: number
|
||||
allowed_models?: string[] | null // 允许使用的模型列表(null = 支持所有模型)
|
||||
capabilities?: Record<string, boolean> | null // 能力标签配置(如 cache_1h, context_1m)
|
||||
// 缓存与熔断配置
|
||||
cache_ttl_minutes: number // 缓存 TTL(分钟),0=禁用
|
||||
max_probe_interval_minutes: number // 熔断探测间隔(分钟)
|
||||
health_score: number
|
||||
consecutive_failures: number
|
||||
last_failure_at?: string
|
||||
request_count: number
|
||||
success_count: number
|
||||
error_count: number
|
||||
success_rate: number
|
||||
avg_response_time_ms: number
|
||||
is_active: boolean
|
||||
note?: string // 备注说明(可选)
|
||||
last_used_at?: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
// 自适应并发字段
|
||||
is_adaptive?: boolean // 是否为自适应模式(max_concurrent=NULL)
|
||||
effective_limit?: number // 当前有效限制(自适应使用学习值,固定使用配置值)
|
||||
learned_max_concurrent?: number
|
||||
// 滑动窗口利用率采样
|
||||
utilization_samples?: Array<{ ts: number; util: number }> // 利用率采样窗口
|
||||
last_probe_increase_at?: string // 上次探测性扩容时间
|
||||
concurrent_429_count?: number
|
||||
rpm_429_count?: number
|
||||
last_429_at?: string
|
||||
last_429_type?: string
|
||||
// 熔断器字段(滑动窗口 + 半开模式)
|
||||
circuit_breaker_open?: boolean
|
||||
circuit_breaker_open_at?: string
|
||||
next_probe_at?: string
|
||||
half_open_until?: string
|
||||
half_open_successes?: number
|
||||
half_open_failures?: number
|
||||
request_results_window?: Array<{ ts: number; ok: boolean }> // 请求结果滑动窗口
|
||||
}
|
||||
|
||||
export interface EndpointHealthDetail {
|
||||
api_format: string
|
||||
health_score: number
|
||||
is_active: boolean
|
||||
}
|
||||
|
||||
export interface EndpointHealthEvent {
|
||||
timestamp: string
|
||||
status: 'success' | 'failed' | 'skipped' | 'started'
|
||||
status_code?: number | null
|
||||
latency_ms?: number | null
|
||||
error_type?: string | null
|
||||
error_message?: string | null
|
||||
}
|
||||
|
||||
export interface EndpointStatusMonitor {
|
||||
api_format: string
|
||||
total_attempts: number
|
||||
success_count: number
|
||||
failed_count: number
|
||||
skipped_count: number
|
||||
success_rate: number
|
||||
provider_count: number
|
||||
key_count: number
|
||||
last_event_at?: string | null
|
||||
events: EndpointHealthEvent[]
|
||||
timeline?: string[]
|
||||
time_range_start?: string | null
|
||||
time_range_end?: string | null
|
||||
}
|
||||
|
||||
export interface EndpointStatusMonitorResponse {
|
||||
generated_at: string
|
||||
formats: EndpointStatusMonitor[]
|
||||
}
|
||||
|
||||
// 公开版事件(不含敏感信息如 provider_id, key_id)
|
||||
export interface PublicHealthEvent {
|
||||
timestamp: string
|
||||
status: string
|
||||
status_code?: number | null
|
||||
latency_ms?: number | null
|
||||
error_type?: string | null
|
||||
}
|
||||
|
||||
// 公开版端点状态监控类型(返回 events,前端复用 EndpointHealthTimeline 组件)
|
||||
export interface PublicEndpointStatusMonitor {
|
||||
api_format: string
|
||||
api_path: string // 本站入口路径
|
||||
total_attempts: number
|
||||
success_count: number
|
||||
failed_count: number
|
||||
skipped_count: number
|
||||
success_rate: number
|
||||
last_event_at?: string | null
|
||||
events: PublicHealthEvent[]
|
||||
timeline?: string[]
|
||||
time_range_start?: string | null
|
||||
time_range_end?: string | null
|
||||
}
|
||||
|
||||
export interface PublicEndpointStatusMonitorResponse {
|
||||
generated_at: string
|
||||
formats: PublicEndpointStatusMonitor[]
|
||||
}
|
||||
|
||||
export interface ProviderWithEndpointsSummary {
|
||||
id: string
|
||||
name: string
|
||||
display_name: string
|
||||
description?: string
|
||||
website?: string
|
||||
provider_priority: number
|
||||
billing_type?: 'monthly_quota' | 'pay_as_you_go' | 'free_tier'
|
||||
monthly_quota_usd?: number
|
||||
monthly_used_usd?: number
|
||||
quota_reset_day?: number
|
||||
quota_last_reset_at?: string // 当前周期开始时间
|
||||
quota_expires_at?: string
|
||||
rpm_limit?: number | null
|
||||
rpm_used?: number
|
||||
rpm_reset_at?: string
|
||||
is_active: boolean
|
||||
total_endpoints: number
|
||||
active_endpoints: number
|
||||
total_keys: number
|
||||
active_keys: number
|
||||
total_models: number
|
||||
active_models: number
|
||||
avg_health_score: number
|
||||
unhealthy_endpoints: number
|
||||
api_formats: string[]
|
||||
endpoint_health_details: EndpointHealthDetail[]
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface HealthStatus {
|
||||
endpoint_id?: string
|
||||
endpoint_health_score?: number
|
||||
endpoint_consecutive_failures?: number
|
||||
endpoint_last_failure_at?: string
|
||||
endpoint_is_active?: boolean
|
||||
key_id?: string
|
||||
key_health_score?: number
|
||||
key_consecutive_failures?: number
|
||||
key_last_failure_at?: string
|
||||
key_is_active?: boolean
|
||||
key_statistics?: Record<string, any>
|
||||
}
|
||||
|
||||
export interface HealthSummary {
|
||||
endpoints: {
|
||||
total: number
|
||||
active: number
|
||||
unhealthy: number
|
||||
}
|
||||
keys: {
|
||||
total: number
|
||||
active: number
|
||||
unhealthy: number
|
||||
}
|
||||
}
|
||||
|
||||
export interface ConcurrencyStatus {
|
||||
endpoint_id?: string
|
||||
endpoint_current_concurrency: number
|
||||
endpoint_max_concurrent?: number
|
||||
key_id?: string
|
||||
key_current_concurrency: number
|
||||
key_max_concurrent?: number
|
||||
}
|
||||
|
||||
export interface Model {
|
||||
id: string
|
||||
provider_id: string
|
||||
global_model_id?: string // 关联的 GlobalModel ID
|
||||
provider_model_name: string // Provider 侧的模型名称(原 name)
|
||||
// 原始配置值(可能为空,为空时使用 GlobalModel 默认值)
|
||||
price_per_request?: number | null // 按次计费价格
|
||||
tiered_pricing?: TieredPricingConfig | null // 阶梯计费配置
|
||||
supports_vision?: boolean | null
|
||||
supports_function_calling?: boolean | null
|
||||
supports_streaming?: boolean | null
|
||||
supports_extended_thinking?: boolean | null
|
||||
supports_image_generation?: boolean | null
|
||||
// 有效值(合并 Model 和 GlobalModel 默认值后的结果)
|
||||
effective_tiered_pricing?: TieredPricingConfig | null // 有效阶梯计费配置
|
||||
effective_input_price?: number | null
|
||||
effective_output_price?: number | null
|
||||
effective_price_per_request?: number | null // 有效按次计费价格
|
||||
effective_supports_vision?: boolean | null
|
||||
effective_supports_function_calling?: boolean | null
|
||||
effective_supports_streaming?: boolean | null
|
||||
effective_supports_extended_thinking?: boolean | null
|
||||
effective_supports_image_generation?: boolean | null
|
||||
is_active: boolean
|
||||
is_available: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
// GlobalModel 信息(从后端 join 获取)
|
||||
global_model_name?: string
|
||||
global_model_display_name?: string
|
||||
}
|
||||
|
||||
export interface ModelCreate {
|
||||
provider_model_name: string // Provider 侧的模型名称(原 name)
|
||||
global_model_id: string // 关联的 GlobalModel ID(必填)
|
||||
// 计费配置(可选,为空时使用 GlobalModel 默认值)
|
||||
price_per_request?: number // 按次计费价格
|
||||
tiered_pricing?: TieredPricingConfig // 阶梯计费配置
|
||||
// 能力配置(可选,为空时使用 GlobalModel 默认值)
|
||||
supports_vision?: boolean
|
||||
supports_function_calling?: boolean
|
||||
supports_streaming?: boolean
|
||||
supports_extended_thinking?: boolean
|
||||
supports_image_generation?: boolean
|
||||
is_active?: boolean
|
||||
config?: Record<string, any>
|
||||
}
|
||||
|
||||
export interface ModelUpdate {
|
||||
provider_model_name?: string
|
||||
global_model_id?: string
|
||||
price_per_request?: number | null // 按次计费价格(null 表示清空/使用默认值)
|
||||
tiered_pricing?: TieredPricingConfig | null // 阶梯计费配置
|
||||
supports_vision?: boolean
|
||||
supports_function_calling?: boolean
|
||||
supports_streaming?: boolean
|
||||
supports_extended_thinking?: boolean
|
||||
supports_image_generation?: boolean
|
||||
is_active?: boolean
|
||||
is_available?: boolean
|
||||
}
|
||||
|
||||
export interface ModelMapping {
|
||||
id: string
|
||||
source_model: string // 别名/源模型名
|
||||
target_global_model_id: string // 目标 GlobalModel ID
|
||||
target_global_model_name: string | null
|
||||
target_global_model_display_name: string | null
|
||||
provider_id: string | null
|
||||
provider_name: string | null
|
||||
scope: 'global' | 'provider'
|
||||
mapping_type: 'alias' | 'mapping'
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface ModelCapabilities {
|
||||
supports_vision: boolean
|
||||
supports_function_calling: boolean
|
||||
supports_streaming: boolean
|
||||
[key: string]: boolean
|
||||
}
|
||||
|
||||
export interface ProviderModelPriceInfo {
|
||||
input_price_per_1m?: number | null
|
||||
output_price_per_1m?: number | null
|
||||
cache_creation_price_per_1m?: number | null
|
||||
cache_read_price_per_1m?: number | null
|
||||
price_per_request?: number | null // 按次计费价格
|
||||
}
|
||||
|
||||
export interface ModelPriceRange {
|
||||
min_input: number | null
|
||||
max_input: number | null
|
||||
min_output: number | null
|
||||
max_output: number | null
|
||||
}
|
||||
|
||||
export interface ModelCatalogProviderDetail {
|
||||
provider_id: string
|
||||
provider_name: string
|
||||
provider_display_name?: string | null
|
||||
model_id?: string | null
|
||||
target_model: string
|
||||
input_price_per_1m?: number | null
|
||||
output_price_per_1m?: number | null
|
||||
cache_creation_price_per_1m?: number | null
|
||||
cache_read_price_per_1m?: number | null
|
||||
cache_1h_creation_price_per_1m?: number | null // 1h 缓存创建价格
|
||||
price_per_request?: number | null // 按次计费价格
|
||||
effective_tiered_pricing?: TieredPricingConfig | null // 有效阶梯计费配置(含继承)
|
||||
tier_count?: number // 阶梯数量
|
||||
supports_vision?: boolean | null
|
||||
supports_function_calling?: boolean | null
|
||||
supports_streaming?: boolean | null
|
||||
is_active: boolean
|
||||
mapping_id?: string | null
|
||||
}
|
||||
|
||||
export interface ModelCatalogItem {
|
||||
global_model_name: string // GlobalModel.name(原 source_model)
|
||||
display_name: string // GlobalModel.display_name
|
||||
description?: string | null // GlobalModel.description
|
||||
aliases: string[] // 所有指向该 GlobalModel 的别名列表
|
||||
providers: ModelCatalogProviderDetail[] // 支持该模型的 Provider 列表
|
||||
price_range: ModelPriceRange // 价格区间
|
||||
total_providers: number
|
||||
capabilities: ModelCapabilities // 能力聚合
|
||||
}
|
||||
|
||||
export interface ModelCatalogResponse {
|
||||
models: ModelCatalogItem[]
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface ProviderAvailableSourceModel {
|
||||
global_model_name: string // GlobalModel.name(原 source_model)
|
||||
display_name: string // GlobalModel.display_name
|
||||
provider_model_name: string // Model.provider_model_name(Provider 侧的模型名)
|
||||
has_alias: boolean // 是否有别名指向该 GlobalModel
|
||||
aliases: string[] // 别名列表
|
||||
model_id?: string | null // Model.id
|
||||
price: ProviderModelPriceInfo
|
||||
capabilities: ModelCapabilities
|
||||
is_active: boolean
|
||||
}
|
||||
|
||||
export interface ProviderAvailableSourceModelsResponse {
|
||||
models: ProviderAvailableSourceModel[]
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface BatchAssignProviderConfig {
|
||||
provider_id: string
|
||||
create_model?: boolean
|
||||
model_config?: ModelCreate
|
||||
model_id?: string
|
||||
}
|
||||
|
||||
export interface BatchAssignModelMappingRequest {
|
||||
global_model_id: string // 要分配的 GlobalModel ID(原 source_model)
|
||||
providers: BatchAssignProviderConfig[]
|
||||
}
|
||||
|
||||
export interface BatchAssignProviderResult {
|
||||
provider_id: string
|
||||
mapping_id?: string | null
|
||||
created_model: boolean
|
||||
model_id?: string | null
|
||||
updated: boolean
|
||||
}
|
||||
|
||||
export interface BatchAssignError {
|
||||
provider_id: string
|
||||
error: string
|
||||
}
|
||||
|
||||
export interface BatchAssignModelMappingResponse {
|
||||
success: boolean
|
||||
created_mappings: BatchAssignProviderResult[]
|
||||
errors: BatchAssignError[]
|
||||
}
|
||||
|
||||
export interface ModelMappingCreate {
|
||||
source_model: string // 源模型名或别名
|
||||
target_global_model_id: string // 目标 GlobalModel ID
|
||||
provider_id?: string | null
|
||||
mapping_type?: 'alias' | 'mapping'
|
||||
is_active?: boolean
|
||||
}
|
||||
|
||||
export interface ModelMappingUpdate {
|
||||
source_model?: string // 源模型名或别名
|
||||
target_global_model_id?: string // 目标 GlobalModel ID
|
||||
provider_id?: string | null
|
||||
mapping_type?: 'alias' | 'mapping'
|
||||
is_active?: boolean
|
||||
}
|
||||
|
||||
export interface UpdateModelMappingRequest {
|
||||
source_model?: string
|
||||
target_global_model_id?: string
|
||||
provider_id?: string | null
|
||||
mapping_type?: 'alias' | 'mapping'
|
||||
is_active?: boolean
|
||||
}
|
||||
|
||||
export interface UpdateModelMappingResponse {
|
||||
success: boolean
|
||||
mapping_id: string
|
||||
message?: string
|
||||
}
|
||||
|
||||
export interface DeleteModelMappingResponse {
|
||||
success: boolean
|
||||
message?: string
|
||||
}
|
||||
|
||||
export interface AdaptiveStatsResponse {
|
||||
adaptive_mode: boolean
|
||||
current_limit: number | null
|
||||
learned_limit: number | null
|
||||
concurrent_429_count: number
|
||||
rpm_429_count: number
|
||||
last_429_at: string | null
|
||||
last_429_type: string | null
|
||||
adjustment_count: number
|
||||
recent_adjustments: Array<{
|
||||
timestamp: string
|
||||
old_limit: number
|
||||
new_limit: number
|
||||
reason: string
|
||||
[key: string]: any
|
||||
}>
|
||||
}
|
||||
|
||||
// ========== 阶梯计费类型 ==========
|
||||
|
||||
/** 缓存时长定价配置 */
|
||||
export interface CacheTTLPricing {
|
||||
ttl_minutes: number
|
||||
cache_creation_price_per_1m: number
|
||||
}
|
||||
|
||||
/** 单个价格阶梯配置 */
|
||||
export interface PricingTier {
|
||||
up_to: number | null // null 表示无上限(最后一个阶梯)
|
||||
input_price_per_1m: number
|
||||
output_price_per_1m: number
|
||||
cache_creation_price_per_1m?: number
|
||||
cache_read_price_per_1m?: number
|
||||
cache_ttl_pricing?: CacheTTLPricing[]
|
||||
}
|
||||
|
||||
/** 阶梯计费配置 */
|
||||
export interface TieredPricingConfig {
|
||||
tiers: PricingTier[]
|
||||
}
|
||||
|
||||
// ========== GlobalModel 类型 ==========
|
||||
|
||||
export interface GlobalModelCreate {
|
||||
name: string
|
||||
display_name: string
|
||||
description?: string
|
||||
official_url?: string
|
||||
icon_url?: string
|
||||
// 按次计费配置(可选,与阶梯计费叠加)
|
||||
default_price_per_request?: number
|
||||
// 阶梯计费配置(必填,固定价格用单阶梯表示)
|
||||
default_tiered_pricing: TieredPricingConfig
|
||||
// 默认能力配置
|
||||
default_supports_vision?: boolean
|
||||
default_supports_function_calling?: boolean
|
||||
default_supports_streaming?: boolean
|
||||
default_supports_extended_thinking?: boolean
|
||||
default_supports_image_generation?: boolean
|
||||
// Key 能力配置 - 模型支持的能力列表
|
||||
supported_capabilities?: string[]
|
||||
is_active?: boolean
|
||||
}
|
||||
|
||||
export interface GlobalModelUpdate {
|
||||
display_name?: string
|
||||
description?: string
|
||||
official_url?: string
|
||||
icon_url?: string
|
||||
is_active?: boolean
|
||||
// 按次计费配置
|
||||
default_price_per_request?: number | null // null 表示清空
|
||||
// 阶梯计费配置
|
||||
default_tiered_pricing?: TieredPricingConfig
|
||||
// 默认能力配置
|
||||
default_supports_vision?: boolean
|
||||
default_supports_function_calling?: boolean
|
||||
default_supports_streaming?: boolean
|
||||
default_supports_extended_thinking?: boolean
|
||||
default_supports_image_generation?: boolean
|
||||
// Key 能力配置 - 模型支持的能力列表
|
||||
supported_capabilities?: string[] | null
|
||||
}
|
||||
|
||||
export interface GlobalModelResponse {
|
||||
id: string
|
||||
name: string
|
||||
display_name: string
|
||||
description?: string
|
||||
official_url?: string
|
||||
icon_url?: string
|
||||
is_active: boolean
|
||||
// 按次计费配置
|
||||
default_price_per_request?: number
|
||||
// 阶梯计费配置(必填)
|
||||
default_tiered_pricing: TieredPricingConfig
|
||||
// 默认能力配置
|
||||
default_supports_vision?: boolean
|
||||
default_supports_function_calling?: boolean
|
||||
default_supports_streaming?: boolean
|
||||
default_supports_extended_thinking?: boolean
|
||||
default_supports_image_generation?: boolean
|
||||
// Key 能力配置 - 模型支持的能力列表
|
||||
supported_capabilities?: string[] | null
|
||||
// 统计数据
|
||||
provider_count?: number
|
||||
alias_count?: number
|
||||
usage_count?: number
|
||||
created_at: string
|
||||
updated_at?: string
|
||||
}
|
||||
|
||||
export interface GlobalModelWithStats extends GlobalModelResponse {
|
||||
total_models: number
|
||||
total_providers: number
|
||||
price_range: ModelPriceRange
|
||||
}
|
||||
|
||||
export interface GlobalModelListResponse {
|
||||
models: GlobalModelResponse[]
|
||||
total: number
|
||||
}
|
||||
Reference in New Issue
Block a user