2025-04-14 21:01:36 +08:00
|
|
|
#include "cdllexport.h"
|
|
|
|
|
|
|
|
#include <asio.hpp>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "../openaiclient.h"
|
|
|
|
|
2025-04-14 21:37:06 +08:00
|
|
|
static std::shared_ptr<OpenAIClient> gc = nullptr;
|
|
|
|
|
2025-04-14 21:01:36 +08:00
|
|
|
class CApiDllExport
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CApiDllExport();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void init_exchange(ExchangeData* ex);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static std::shared_ptr<OpenAIClient> client;
|
|
|
|
static std::string server_ip;
|
|
|
|
static unsigned int port;
|
|
|
|
asio::io_context io_context;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::shared_ptr<OpenAIClient> CApiDllExport::client = nullptr;
|
|
|
|
|
|
|
|
CApiDllExport::CApiDllExport()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CApiDllExport::init_exchange(ExchangeData* ex)
|
|
|
|
{
|
|
|
|
if (ex == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ex->content = nullptr;
|
|
|
|
ex->ck = 0;
|
|
|
|
ex->pk = 0;
|
|
|
|
ex->len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_api(const char* ip, unsigned int port)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExchangeData* ask_openai(const char* content)
|
|
|
|
{
|
|
|
|
ExchangeData* ret = (ExchangeData*)malloc(sizeof(ExchangeData));
|
|
|
|
if (ret == nullptr) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
CApiDllExport::init_exchange(ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void free_exchange_data(ExchangeData* data)
|
|
|
|
{
|
|
|
|
}
|