package com.ruoyi.llm.service;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.io.IOException;
import java.util.List;

public interface ILangChainMilvusService {

    /**
     * 获取进度
     *
     * @return 结果
     */
    public String getProcess();

    /**
     * 导入知识库文件
     * @return
     */
    public int insertLangchainEmbeddingDocument(MultipartFile[] fileList, String collectionName);

    /**
     * 从Milvus检索相关文档
     * @return
     */
    public List<JSONObject> retrieveFromMilvus(String collectionName, String query, int topK);

    /**
     * 从Milvus检索相关文档及相关度
     * @return
     */
    public List<JSONObject> similarityFromMilvus(String collectionName, String query, int topK);

    /**
     * 调用LLM生成回答
     * @return
     */
    public SseEmitter generateAnswer(String topicId, String question);

    /**
     * 调用LLM+RAG（知识库）生成回答
     * @return
     */
    public SseEmitter generateAnswerWithCollection(String topicId, String question, List<JSONObject> contexts);

    /**
     * 调用LLM+RAG（外部文件）生成回答
     * @return
     */
    public SseEmitter generateAnswerWithDocument(String topicId, String chatId, String question) throws Exception;

    /**
     * 调用LLM+RAG（外部文件+知识库）生成回答
     * @return
     */
    public SseEmitter generateAnswerWithDocumentAndCollection(String topicId, String question,  List<JSONObject> requests) throws Exception;

    /**
     * 获取二级标题下三级标题列表
     * @return
     */
    public List<String> extractSubTitles(String filename, String question) throws IOException;
}
