import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AiModelVO, AiModelForm, AiModelQuery } from '@/api/ai/base/aiModel/types';

/**
 * 查询AI模型列表
 * @param query
 * @returns {*}
 */

export const listAiModel = (query?: AiModelQuery): AxiosPromise<AiModelVO[]> => {
  return request({
    url: '/ai/aiModel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询AI模型详细
 * @param modelId
 */
export const getAiModel = (modelId: string | number): AxiosPromise<AiModelVO> => {
  return request({
    url: '/ai/aiModel/' + modelId,
    method: 'get'
  });
};

/**
 * 新增AI模型
 * @param data
 */
export const addAiModel = (data: AiModelForm) => {
  return request({
    url: '/ai/aiModel',
    method: 'post',
    data: data
  });
};

/**
 * 修改AI模型
 * @param data
 */
export const updateAiModel = (data: AiModelForm) => {
  return request({
    url: '/ai/aiModel',
    method: 'put',
    data: data
  });
};

/**
 * 删除AI模型
 * @param modelId
 */
export const delAiModel = (modelId: string | number | Array<string | number>) => {
  return request({
    url: '/ai/aiModel/' + modelId,
    method: 'delete'
  });
};


/**
 * 下拉框查询AI模型列表
 * @param query
 * @returns {*}
 */
export function getAiModelList (query) {
    return request({
        url: '/ai/aiModel/getAiModelList',
        method: 'get',
        params: query
    });
};


/**
 * 测试AI模型调用API是否成功
 * @returns {*}
 * @param provider
 * @param data
 */
export function testAIModel (provider,data) {
  return request({
    url: '/ai/aiModel/testAIModel?provider='+provider,
    method: 'post',
    data: data
  });
};
