// @ts-ignore
/* eslint-disable */
import request from '@repo/api-client'

/** 检查模型 POST /api/ai/model/check */
export async function postAiModelCheck(
  body: {
    name: string
    type: string
    source: string
    provider: string
    api_key: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    isAuthorized: boolean
    result?: Record<string, any>
  }>('/api/ai/model/check', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 创建模型 POST /api/ai/model/create */
export async function postAiModelCreate(
  body: {
    name: string
    title: string
    description: string
    type: string
    source: string
    provider: string
    base_url: string
    api_key: string
    custom_headers: Record<string, any>
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/model/create',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 删除模型 POST /api/ai/model/delete */
export async function postAiModelOpenApiDelete(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/model/delete',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 模型详情 POST /api/ai/model/info */
export async function postAiModelInfo(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      creationTime: string
      creatorUserId: string
      description: string
      id: string
      isDeleted: boolean
      is_default: boolean
      name: string
      parameters: {
        api_key: string
        base_url: string
        embedding_parameters: { dimension: number; truncate_prompt_tokens: number }
        provider: string
      }
      provider: string
      source: string
      status: string
      title: string
      type: string
      updateTime: string
    }
    isAuthorized: boolean
  }>('/api/ai/model/info', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取模型分页列表 POST /api/ai/model/pageList */
export async function postAiModelPageList(
  body: {
    keyword: string
    type: string
    source: string
    pageIndex: number
    pageSize: number
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      currentPage: number
      hasNextPage: boolean
      hasPreviousPage: boolean
      model: {
        creationTime?: string
        creatorUserId?: string
        description?: string
        id?: string
        isDeleted?: boolean
        is_default?: boolean
        name?: string
        parameters: {
          api_key: string
          base_url: string
          embedding_parameters: { dimension: number; truncate_prompt_tokens: number }
          provider: string
        }
        provider?: string
        source?: string
        status?: string
        title?: string
        type?: string
        updateTime?: string
      }[]
      pageSize: number
      totalCount: number
      totalPages: number
    }
    isAuthorized: boolean
  }>('/api/ai/model/pageList', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 根据模型类型获取支持的服务商列表及配置信息 POST /api/ai/model/providers */
export async function postAiModelProviders(options?: { [key: string]: any }) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      defaultUrls: { chat: string; embedding: string; rerank: string; vllm: string }
      description: string
      label: string
      modelTypes: string[]
      value: string
    }[]
    isAuthorized: boolean
  }>('/api/ai/model/providers', {
    method: 'POST',
    ...(options || {})
  })
}

/** 更新模型 POST /api/ai/model/update */
export async function postAiModelUpdate(
  body: {
    id: string
    name: string
    title: string
    description: string
    base_url: string
    api_key: string
    custom_headers: Record<string, any>
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/model/update',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}
