import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { modelConfigForm, ModelNameType, ModelList, ModelListVO } from './types';

/**
 * 新增模型
 */
export const addModel = (data:modelConfigForm) => {
  return request({
    url:'/ai/model/config',
    method: 'post',
    data:data
  })
};
/**
 * 修改模型
 */
export const editModel = (data:modelConfigForm) => {
  return request({
    url:'/ai/model/config',
    method: 'put',
    data:data
  })
}

/**
 * 查询模型配置列表
 */
export const queryModelList = (data:ModelList) : AxiosPromise<ModelListVO> =>{
  return request({
    url:'/ai/model/config/list',
    method: 'get',
    data:data
  })
}

/**
 * 根据id删除模型
 */
export const deleteModel = (id:Number) => {
  return request({
    url:`/ai/model/config/${id}`,
    method:'delete',
  })
}

/**
 * 根据模型类型和名称 查询模型配置列表
 */
export const queryModelByNameType = (data:ModelNameType):AxiosPromise<ModelListVO> => {
  return request({
    url:'/ai/model/config/getModelConfig',
    method: 'get',
    data:data
  })
}

/**
 * 根据模型名称 获取默认模型
 */
export const getModelByType = (data:string):AxiosPromise<ModelListVO> => {
  return request({
    url:'/ai/model/config/getDefaultModelConfig',
    method: 'get',
    data:data
  })
}
/**
 * 启用或禁用模型
 */
export const toggleStatus = (data:boolean,id:Number) => {
  return request({
    url:`/ai/model/config/toggle/${id}`,
    method:'put',
    data:data
  })
}

export const exportModel = (data:ModelList) =>{
  return request({
    url:'/ai/model/config/export',
    method:'post',
    data:data
  })
}
