Files
Yi.Admin/Yi.Ai.Vue3/src/api/model/index.ts

105 lines
2.3 KiB
TypeScript
Raw Normal View History

2025-06-17 22:37:37 +08:00
import type { GetSessionListVO } from './types';
2025-11-29 16:43:08 +08:00
import { del, get, post, put } from '@/utils/request';
2025-06-17 22:37:37 +08:00
// 获取当前用户的模型列表
export function getModelList() {
2025-06-19 23:45:22 +08:00
// return get<GetSessionListVO[]>('/system/model/modelList');
2025-06-28 23:07:32 +08:00
return get<GetSessionListVO[]>('/ai-chat/model').json();
2025-06-17 22:37:37 +08:00
}
// 申请ApiKey
export function applyApiKey() {
return post<any>('/token').json();
}
// 获取ApiKey
export function getApiKey() {
return get<any>('/token').json();
}
// 查询充值记录
export function getRechargeLog() {
return get<any>('/recharge/account').json();
}
// 查询用户近7天token消耗
export function getLast7DaysTokenUsage() {
return get<any>('/usage-statistics/last7Days-token-usage').json();
}
// 查询用户token消耗各模型占比
export function getModelTokenUsage() {
return get<any>('/usage-statistics/model-token-usage').json();
}
2025-11-29 16:43:08 +08:00
// 以下为新增接口
// 获取当前用户得token列表
export function getTokenList() {
return get<any>('/token/list').json();
}
/*
[
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string",
"apiKey": "string",
"expireTime": "2025-11-29T07:34:23.850Z",
"premiumQuotaLimit": 0,
"premiumUsedQuota": 0,
"isDisabled": true,
"creationTime": "2025-11-29T07:34:23.850Z"
}
] */
// 创建token
export function createToken(data: any) {
return post<any>('/token', data).json();
}
/*
data:
{
"name": "string",
"expireTime": "2025-11-29T07:35:10.458Z",
"premiumQuotaLimit": 0
} */
/*
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string",
"apiKey": "string",
"expireTime": "2025-11-29T07:35:10.459Z",
"premiumQuotaLimit": 0,
"premiumUsedQuota": 0,
"isDisabled": true,
"creationTime": "2025-11-29T07:35:10.459Z"
} */
// 编辑token
export function editToken(data: any) {
return put('/token', data).json();
}
/*
data:
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string",
"expireTime": "2025-11-29T07:36:49.589Z",
"premiumQuotaLimit": 0
}
*/
// 删除token
export function deleteToken(id: string) {
return del(`/token/${id}`).json();
}
// 启用token
export function enableToken(id: string) {
return post(`/token/${id}/enable`).json();
}
// 禁用token
export function disableToken(id: string) {
return post(`/token/${id}/disable`).json();
}