-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
82 lines (64 loc) · 1.97 KB
/
test.cpp
File metadata and controls
82 lines (64 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <bits/stdc++.h>
#include "json.hpp"
#include "httplib.h"
using namespace std;
using json = nlohmann::json;
vector<string> to_lines(const string& content, bool skip_empty = true) {
vector<string> lines;
istringstream stream(content);
string line;
while (getline(stream, line)) {
if (skip_empty && line.empty()) {
continue;
}
lines.push_back(line);
}
return lines;
}
int main(){
// json request_payload = {
// {"model", "Qwen/Qwen3.5-2B"},
// {"messages", {
// {
// {"role", "user"},
// {"content", "Hello, how are you?"}
// }
// }}
// };
// string base_url = "http://localhost:8000/v1/chat/completions";
// httplib::Client cli("localhost", 8000);
// auto res = cli.Post(base_url, request_payload.dump(), "application/json");
// if(res && res->status == 200){
// cout<<"response from vllm successful"<<endl;
// cout<<"response body: "<<res->body<<endl;
// }else{
// cout<<"response from vllm failed"<<endl;
// if(res){
// cout<<"status code: "<<res->status<<endl;
// cout<<"response body: "<<res->body<<endl;
// }else{
// cout<<"error code: "<<res.error()<<endl;
// }
// }
// json response_json = json::parse(res->body);
// cout<<"response json: "<<response_json["choices"][0]["message"]["reasoning"]<<endl;
// system("tree .");
system("tree . > tree_output.txt");
// read the file tree_output.txt and store the content in a string variable
ifstream tree_file("tree_output.txt");
if (!tree_file.is_open()) {
cerr << "Failed to open tree_output.txt" << endl;
return 1;
}
string tree_content((istreambuf_iterator<char>(tree_file)), istreambuf_iterator<char>());
tree_file.close();
string tree_output = tree_content;
cout<<"tree output: "<<endl<<tree_output<<endl;
vector<string> lines = to_lines(tree_output);
// print the lines
cout<<"lines: "<<endl;
for(const auto& line : lines){
cout<<line<<endl;
}
return 0;
}