Files
knowai/api/modules/model.ts
tobegold574 6a81b7bb13
Some checks reported errors
continuous-integration/drone/push Build was killed
feat(image): 新建 knowai-core:1.0.0 镜像并完成推送
- 搭建 api、auth、utils 等逻辑模块
- 通过 tsc、eslint、vitest 测试验证

BREAKING CHANGE: 新镜像分支
2025-11-10 20:20:25 +08:00

30 lines
993 B
TypeScript

import type { AxiosRequestConfig } from 'axios';
import type { ApiClient } from '../types';
import type {
GetAIPlazaRequest,
GetAIPlazaResponse,
GetModelDetailRequest,
GetModelDetailResponse,
GetModelCommentsRequest,
GetModelCommentsResponse
} from '@/types/model/api';
// AI模型API服务工厂函数
export const modelApi = (client: ApiClient) => ({
// 获取AI模型广场数据
getAIPlaza: (params?: GetAIPlazaRequest): Promise<GetAIPlazaResponse> => {
const config: AxiosRequestConfig = params ? { params } : {};
return client.get('/models/plaza', config);
},
// 获取模型详情
getModelDetail: ({ modelId, ...params }: GetModelDetailRequest): Promise<GetModelDetailResponse> => {
return client.get(`/models/${modelId}`, { params });
},
// 获取模型评论
getModelComments: ({ modelId, ...params }: GetModelCommentsRequest): Promise<GetModelCommentsResponse> => {
return client.get(`/models/${modelId}/comments`, { params });
}
});