#ifndef JSON_DATA
#define JSON_DATA

#include <filesystem>
#include <fstream>
#include <nlohmann/json.hpp>
#include <optional>
#include <string>
#include <vector>

namespace fs = std::filesystem;
struct Message {
    std::string message_content;
    std::string reasoning_content;
    std::string id;
    int prompt_tokens{};
    int completion_tokens{};
    int total_tokens{};
};

using json = nlohmann::json;
class CJsonOper
{
public:
    CJsonOper(const std::string& user_name, const std::string& model, const std::string& assistant_name);
    ~CJsonOper();

public:
    std::string format_request(const std::string& content);
    std::string multi_format_reuqest(const std::string& content, size_t per_sec_size);
    Message parse(const std::string& data);
    static bool save_md(const std::string& data, const std::string& id);
    static bool read_txt(const std::string& path, std::string& out);
    static std::vector<std::string> split(const std::string& input, const std::string& delimiter);
    static size_t get_u8_len(unsigned char ch);
    static std::string get_all_dir_content(const std::string& dir, const std::string& types);
    static std::string trim(const std::string& input);

private:
    std::string user_{};
    std::string model_{};
    std::string assistant_{};
};

#endif