/*
 * Copyright 2024 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef SERVICES_ASSISTANT_FILE_INFERENCE_INTERFACE_H
#define SERVICES_ASSISTANT_FILE_INFERENCE_INTERFACE_H

#include <future>
#include <string>

#include "assistant/intentdialoguemanager/dialoguemessage.h"

class FileInferenceInterface {
public:
    virtual ~FileInferenceInterface() = default;

    virtual std::future<DialogueData::FileSearchIdentifier> ragSearchText(const std::string& knowledgeBaseName,
                                                                          const std::string& text, bool useDefault) = 0;

    // 解析文件内容
    virtual DialogueData::CallSuccessIdentifier fileContent(const std::string& knowledgeBaseName,
                                                            const std::string& docFilePath) = 0;

    // 创建知识库
    virtual std::future<DialogueData::KnowledgeBaseResult> createFileKnowledgeBase() = 0;

    // 删除知识库
    virtual void deleteFileKnowledgeBase(const std::string& knowledgeBaseName) = 0;

    // 更新知识库
    virtual DialogueData::FileSearchIdentifier updateFileKnowledgeBase(const std::string& knowledgeBaseName,
                                                                       const std::string& docFilePath) = 0;
};

class TextEmbeddingInterface {
public:
    virtual ~TextEmbeddingInterface() = default;

    // 文本向量化接口
    virtual DialogueCallback::TextEmbeddingResult textVectorization(const std::string& textStr) = 0;

    void setTextEmbeddingCallback(const DialogueCallback::TextEmbeddingCallback& callback) {
        textEmbeddingCallback_ = callback;
    }

protected:
    void callTextEmbeddingCallback(const DialogueCallback::TextEmbeddingResult& textEmbedding) {
        if (textEmbeddingCallback_ != nullptr) {
            textEmbeddingCallback_(textEmbedding);
        }
    }

protected:
    DialogueCallback::TextEmbeddingCallback textEmbeddingCallback_{nullptr};
};

#endif  // SERVICES_ASSISTANT_FILE_INFERENCE_INTERFACE_H
