40 lines
944 B
C++
40 lines
944 B
C++
#include <asio.hpp>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <thread>
|
|
|
|
#include "../openaiclient.h"
|
|
#include "communicate.hpp"
|
|
|
|
int main()
|
|
{
|
|
#ifdef _WIN32
|
|
system("chcp 65001");
|
|
#endif
|
|
|
|
asio::io_context io_context;
|
|
OpenAIClient client(io_context);
|
|
|
|
if (!client.connect("127.0.0.1", 9999)) {
|
|
return -1;
|
|
}
|
|
|
|
std::thread t([&io_context]() { io_context.run(); });
|
|
|
|
std::string text = "将【天文历】翻译为英文,直接给出结果。";
|
|
// std::string text = "This is a test.";
|
|
FrameData* frame = client.ask_openai(text);
|
|
if (frame) {
|
|
std::cout << "type: " << frame->type << std::endl;
|
|
std::cout << "data: " << frame->data << std::endl;
|
|
std::cout << "len: " << frame->len << std::endl;
|
|
std::cout << "protk: " << frame->protk << std::endl;
|
|
std::cout << "coptk: " << frame->coptk << std::endl;
|
|
}
|
|
|
|
delete frame;
|
|
t.join();
|
|
|
|
return 0;
|
|
}
|