import request, { RequestEventStreamConfig } from '@/utils/request'

//获取技能列表
export function getSkillLists(data: any) {
    return request.get({ url: '/ai/skill', data })
}
//获取创作列表
export function getCreationLists(data: { keyword: string }) {
    return request.get({ url: '/ai/creation', data })
}

export function getSamplesLists() {
    return request.get({ url: '/ai/question' })
}

export function questionChat(data: any) {
    return request.post({ url: '/chat_records/chat', data }, { isAuth: true })
}

// 对话记录
export function getChatRecord(data: any) {
    return request.get({
        url: '/chats/chatRecord',
        data
    })
}

//清空会话
export function cleanChatRecord(data: any) {
    return request.post(
        {
            url: '/chats/chatClean',
            data
        },
        { isAuth: true }
    )
}

//清空会话
export function delChatRecord(data: any) {
    return request.post(
        {
            url: '/chats/record/del',
            data
        },
        { isAuth: true }
    )
}

//收藏
export function collectChatRecord(data: any) {
    return request.post({ url: '/chats/addCollect', data }, { isAuth: true })
}
//取消收藏
export function cancelCollectChatRecord(data: any) {
    return request.post({ url: '/chats/cancelCollect', data }, { isAuth: true })
}

//收藏列表
export function getCollectChatRecordLists(data: any) {
    return request.get({ url: '/chats/listCollect', data })
}

export function getCreationDetail(data: any) {
    return request.get({ url: '/ai/creation/detail', data })
}

export function getSkillDetail(data: any) {
    return request.get({ url: '/ai/skill/detail', data })
}

export function chatSendText(data: any, config: RequestEventStreamConfig) {
    return request.eventStream({ url: '/chats/chatSend', data, method: 'POST' }, config)
}

// 对话分类列表
export function getChatCategoryLists(data: any) {
    return request.get({ url: '/ai/category', data })
}

// 对话分类新增
export function chatCategoryAdd(data: any) {
    return request.post({ url: '/ai/category/add', data }, { isAuth: true })
}

// 对话分类编辑
export function chatCategoryEdit(data: any) {
    return request.post({ url: '/ai/category/update', data }, { isAuth: true })
}

// 对话分类删除
export function chatCategoryDelete(data: any) {
    return request.post({ url: '/ai/category/del', data }, { isAuth: true })
}

// 对话分类清空
export function chatCategoryClear() {
    return request.post({ url: '/ai/category/delAll' }, { isAuth: true })
}

// 创作
export function creationChat(data: any, config: RequestEventStreamConfig) {
    return request.eventStream({ url: '/chat/creationChat', data, method: 'POST' }, config)
}

//获取聊天模型接口
export function getChatModelApi() {
    return request.get({ url: '/chats/getChatBillingConfigList' })
}

export function getChatBroadcast(data: any) {
    return request.post({ url: '/voice/execute', data })
}

export function getChatVoiceGenerate(data: any) {
    return request.post({ url: '/chats/voiceGenerate', data })
}

export function audioTransfer(filePath: string, formData: Record<string, any>) {
    return request.uploadFile({
        url: '/voice/voiceTransfer',
        filePath,
        formData,
        name: 'file'
    })
}

export function getPlugLists() {
    return request.get({ url: '/chats/plugLists' })
}
