41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
#ifndef JSON_DATA
|
|
#define JSON_DATA
|
|
|
|
#include <nlohmann/json.hpp>
|
|
#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);
|
|
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 trim(const std::string& input);
|
|
|
|
private:
|
|
std::string user_;
|
|
std::string model_;
|
|
std::string assistant_;
|
|
};
|
|
|
|
#endif
|