初始提交:OCI 面板前端(含 GenAI 网关一期)

This commit is contained in:
Wang Defa
2026-07-09 15:31:29 +08:00
commit db45a669e3
135 changed files with 25220 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
import { request } from './request'
import type { AiCallLog, AiChannel, AiContentLog, AiKey, AiModel, AiModelCacheItem } from '@/types/api'
// ---- 网关密钥 ----
export function listAiKeys(): Promise<AiKey[]> {
return request<{ items: AiKey[] }>('/ai-keys').then((r) => r.items)
}
export interface CreateAiKeyRequest {
name: string
value?: string
group?: string
}
/** 创建密钥;key 为明文,仅本次响应返回 */
export function createAiKey(body: CreateAiKeyRequest): Promise<{ key: string; item: AiKey }> {
return request('/ai-keys', { method: 'POST', body })
}
export function updateAiKey(
id: number,
body: { name?: string; enabled?: boolean; group?: string },
): Promise<void> {
return request(`/ai-keys/${id}`, { method: 'PUT', body })
}
export function deleteAiKey(id: number): Promise<void> {
return request(`/ai-keys/${id}`, { method: 'DELETE' })
}
/** 设置密钥内容日志窗口:0 关闭,>0 从现在起开启 N 小时(上限 168 = 7 天),返回最新密钥 */
export function updateAiKeyContentLog(id: number, hours: number): Promise<AiKey> {
return request(`/ai-keys/${id}/content-log`, { method: 'PUT', body: { hours } })
}
// ---- 渠道(号池)----
export function listAiChannels(): Promise<AiChannel[]> {
return request<{ items: AiChannel[] }>('/ai-channels').then((r) => r.items)
}
export interface AiChannelInput {
ociConfigId?: number
region?: string
name?: string
group?: string
enabled?: boolean
priority?: number
weight?: number
}
export function createAiChannel(body: AiChannelInput): Promise<AiChannel> {
return request('/ai-channels', { method: 'POST', body })
}
export function updateAiChannel(id: number, body: AiChannelInput): Promise<void> {
return request(`/ai-channels/${id}`, { method: 'PUT', body })
}
export function deleteAiChannel(id: number): Promise<void> {
return request(`/ai-channels/${id}`, { method: 'DELETE' })
}
export function probeAiChannel(id: number): Promise<AiChannel> {
return request(`/ai-channels/${id}/probe`, { method: 'POST' })
}
export function syncAiChannelModels(id: number): Promise<AiModelCacheItem[]> {
return request<{ items: AiModelCacheItem[] }>(`/ai-channels/${id}/sync-models`, {
method: 'POST',
}).then((r) => r.items)
}
// ---- 聚合模型与调用日志 ----
export function listAiModels(): Promise<AiModel[]> {
return request<{ items: AiModel[] }>('/ai-models').then((r) => r.items)
}
export function listAiCallLogs(params: {
page: number
size: number
}): Promise<{ items: AiCallLog[]; total: number }> {
return request('/ai-logs', { query: params })
}
/** 内容日志(红线例外);keyId / callLogId 可选过滤 */
export function listAiContentLogs(params: {
page: number
size: number
keyId?: number
callLogId?: number
}): Promise<{ items: AiContentLog[]; total: number }> {
return request('/ai-content-logs', { query: params })
}