import { frogHttp, cowHttp } from '@/lib/http/instances'
import {
  AiDictOutResponse,
  AiUserBaseListOutput,
  AiUserInfoOutput,
  CreateOrEditAiRequest,
  GenAiUserContentOutput,
  GenerateContentRequest,
  GenerateImageOutput,
  GenerateImageRequest,
  GetImageGenerateResultRequest,
  GetImageGenerateResultResponse,
} from './types'

export const createService = {
  // 获取AI字典信息
  dict: (): Promise<AiDictOutResponse> => {
    return frogHttp.post('/web/get-ai-dict')
  },

  // 创建或编辑AI
  createOrEditAI: (data: CreateOrEditAiRequest): Promise<{ aiId: number }> => {
    return frogHttp.post('/web/ai-user/create-edit', data)
  },

  editAIAvatar: (data: { aiId: number; userHead: string }): Promise<void> => {
    return frogHttp.post('/web/ai-user/edit-head-img', data)
  },

  // 删除AI
  deleteAI: (data: { aiId: number }): Promise<void> => {
    return frogHttp.post('/web/ai-user/del', data)
  },

  // 获取AI信息
  getAI: (data: { aiId: number }): Promise<AiUserInfoOutput> => {
    return frogHttp.post('/web/ai-user/get-my-ai-user/info', data)
  },

  // 使用AI生成内容
  generateContent: (data: GenerateContentRequest): Promise<GenAiUserContentOutput> => {
    return cowHttp.post('/web/gen/user-content-v1', data)
  },

  // 生成图片
  generateImage: (data: GenerateImageRequest): Promise<GenerateImageOutput> => {
    return cowHttp.post('/web/gen/image-ct', data)
  },

  // 轮询查询图片生成结果
  getImageGenerateResult: (
    data: GetImageGenerateResultRequest
  ): Promise<GetImageGenerateResultResponse> => {
    return cowHttp.post('/web/gen/image-pl', data)
  },

  // 获取AI角色列表
  getAICharacterList: (): Promise<AiUserBaseListOutput[]> => {
    return frogHttp.post('/web/ai-user-search/base-list')
  },
}
