package com.cy.guoyan.admin.module.ai.service.chatknowledgedataset;

import java.io.IOException;
import java.util.*;
import javax.validation.*;

import com.alibaba.fastjson.JSONObject;
import com.cy.guoyan.admin.module.ai.controller.admin.chatknowledgedataset.vo.ChatKnowledgeDatasetPageReqVO;
import com.cy.guoyan.admin.module.ai.controller.admin.chatknowledgedataset.vo.ChatKnowledgeDatasetSaveReqVO;
import com.cy.guoyan.admin.module.ai.dal.dataobject.chatknowledgedataset.ChatKnowledgeDatasetDO;
import com.cy.guoyan.admin.framework.common.pojo.PageResult;
import org.springframework.web.multipart.MultipartFile;

/**
 * AI 知识库 Service 接口
 *
 * @author 管理员
 */
public interface ChatKnowledgeDatasetService {

    /**
     * 创建AI 知识库
     *
     * @param createReqVO 创建信息
     * @return 编号
     */
    Long createChatKnowledgeDataset(@Valid ChatKnowledgeDatasetSaveReqVO createReqVO) throws IOException;

    /**
     * 更新AI 知识库
     *
     * @param updateReqVO 更新信息
     */
    void updateChatKnowledgeDataset(@Valid ChatKnowledgeDatasetSaveReqVO updateReqVO);

    /**
     * 删除AI 知识库
     *
     * @param id 编号
     */
    void deleteChatKnowledgeDataset(Long id) throws IOException;

    /**
     * 获得AI 知识库
     *
     * @param id 编号
     * @return AI 知识库
     */
    ChatKnowledgeDatasetDO getChatKnowledgeDataset(Long id);

    /**
     * 获得AI 知识库分页
     *
     * @param pageReqVO 分页查询
     * @return AI 知识库分页
     */
    PageResult<ChatKnowledgeDatasetDO> getChatKnowledgeDatasetPage(ChatKnowledgeDatasetPageReqVO pageReqVO);

    int syncFromDify()throws IOException;

    List<ChatKnowledgeDatasetDO> getChatKnowledgeDatasetList(ChatKnowledgeDatasetPageReqVO pageReqVO);

    JSONObject createDocumentByFile(MultipartFile file,String dataJson,String datasetId)throws IOException;

    JSONObject getDocumentIndexingStatus(String datasetId, String batch) throws IOException;

    void deleteDocument(String datasetId, String documentId) throws IOException;

    JSONObject addDocumentSegments(String datasetId, String documentId, List<Map<String, Object>> segments) throws IOException;

    JSONObject listDocuments(String datasetId, String keyword, Integer page, Integer limit) throws IOException;

    JSONObject listDocumentSegments(String datasetId, String documentId, String keyword, String status) throws IOException;

    void deleteDocumentSegment(String datasetId, String documentId, String segmentId) throws IOException;

    JSONObject getUploadedFileInfo(String datasetId, String documentId) throws IOException;

    JSONObject updateDocumentSegment(String datasetId, String documentId, String segmentId, String content, String answer, List<String> keywords, Boolean enabled) throws IOException;

    JSONObject retrieveFromDataset(ChatKnowledgeDatasetSaveReqVO createReqVO) throws IOException;
}