/*
 * 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 CHAT_MESSAGES_H
#define CHAT_MESSAGES_H

#include <string>
#include <vector>

#include "utils/logger.h"

enum class ChatMessageType { SYSTEM, USER, ASSISTANT };

struct ChatMessage {
    ChatMessageType type_{ChatMessageType::USER};
    std::string message_;
};

class ChatMessages {
public:
    std::string generateJsonString();

    void setSystemMessage(const std::string& systemMessage);

    void setSystemMessage(const std::string& systemMessage, int taskId);

    void addUserQuestion(const std::string& question);

    void addAssistantReply(const std::string& reply);

    void setTopK(int topK) { topK_ = topK; }

    void clear() {
        systemMessage_.clear();
        messages_.clear();
        taskId_ = -1;
        LOGD("clear");
    }

    void setTaskId(int taskId) { taskId_ = taskId; }

private:
    std::string systemMessage_;
    std::vector<ChatMessage> messages_;
    int topK_{};
    int taskId_{-1};
};

#endif  // CHAT_MESSAGES_H
