diff --git a/src/apis/Model.ts b/src/apis/Model.ts index b51a589..ea7b45d 100644 --- a/src/apis/Model.ts +++ b/src/apis/Model.ts @@ -1,5 +1,49 @@ import { get, getApiBaseURL, post } from '../utlis/request' -import type { TextToTextParams } from '@/types/model' +import type { + AiModelItem, + AiModelType, + AllModelResponse, + Model, + TextToTextParams, +} from '@/types/model' + +// 获取可用模型列表原始接口 (model_type: all/t2i/t2v/i2v) +export const getAiModelsRaw = (params?: { model_type?: AiModelType }): Promise<{ code: number; message: string; data: AiModelItem[] | null }> => + get('/v2/ai/models', params) + +/** + * 兼容旧 AllModel 返回结构的模型列表获取 + * - 将新接口 /v2/ai/models 的返回适配为 { status, data: Model[] } + * - 现有页面逻辑(input_fields、价格、参数构造)无需改动 + */ +export const getAiModels = async (modelType: AiModelType): Promise => { + const res = await getAiModelsRaw({ model_type: modelType }) + const list: Model[] = Array.isArray(res?.data) + ? res.data.map((item): Model => ({ + id: String(item.id ?? item.model ?? ''), + name: String(item.name ?? item.model ?? ''), + model: String(item.model ?? item.name ?? ''), + description: String(item.description ?? ''), + llmcatelogid: String(item.llmcatelogid ?? modelType), + iconid: String(item.iconid ?? ''), + upappid: String(item.upappid ?? ''), + apiname: String(item.apiname ?? item.model ?? ''), + providerid: String(item.providerid ?? ''), + ownerid: String(item.ownerid ?? ''), + enabled_date: String(item.enabled_date ?? ''), + expired_date: String(item.expired_date ?? ''), + query_apiname: String(item.query_apiname ?? ''), + query_period: Number(item.query_period ?? 0), + ppid: String(item.ppid ?? ''), + input_fields: Array.isArray(item.input_fields) ? (item.input_fields as Model['input_fields']) : [], + })) + : [] + + return { + status: res?.code === 0 ? 'ok' : 'error', + data: list, + } +} // 文生视频 export const textvideo = (data:D):Promise =>post('/llmage/vidu_inference.dspy',data) diff --git a/src/components/img/ImgImg.vue b/src/components/img/ImgImg.vue index 1ad8746..4c2e27f 100644 --- a/src/components/img/ImgImg.vue +++ b/src/components/img/ImgImg.vue @@ -136,9 +136,8 @@