@@ -30,7 +30,40 @@ extern "C" __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int
30
30
#define CP_UTF8 65001
31
31
#endif
32
32
33
+ <<<<<<< HEAD
33
34
int32_t get_num_physical_cores () {
35
+ =======
36
+ std::string process_escapes (const char * input) {
37
+ std::string output;
38
+
39
+ if (input != nullptr ) {
40
+ std::size_t input_len = std::strlen (input);
41
+ output.reserve (input_len);
42
+
43
+ for (std::size_t i = 0 ; i < input_len; ++i) {
44
+ if (input[i] == ' \\ ' && i + 1 < input_len) {
45
+ switch (input[++i]) {
46
+ case ' n' : output.push_back (' \n ' ); break ;
47
+ case ' t' : output.push_back (' \t ' ); break ;
48
+ case ' \' ' : output.push_back (' \' ' ); break ;
49
+ case ' \" ' : output.push_back (' \" ' ); break ;
50
+ case ' \\ ' : output.push_back (' \\ ' ); break ;
51
+ default : output.push_back (' \\ ' );
52
+ output.push_back (input[i]); break ;
53
+ }
54
+ } else {
55
+ output.push_back (input[i]);
56
+ }
57
+ }
58
+ }
59
+
60
+ return output;
61
+ }
62
+
63
+ bool gpt_params_parse (int argc, char ** argv, gpt_params & params) {
64
+ // determine sensible default number of threads.
65
+ // std::thread::hardware_concurrency may not be equal to the number of cores, or may return 0.
66
+ >>>>>>> 7f8e899 (Process escape sequences given in prompts)
34
67
#ifdef __linux__
35
68
std::ifstream cpuinfo (" /proc/cpuinfo" );
36
69
std::string line;
@@ -91,13 +124,17 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
91
124
invalid_param = true ;
92
125
break ;
93
126
}
127
+ <<<<<<< HEAD
94
128
params.prompt = argv[i];
95
129
} else if (arg == " --session" ) {
96
130
if (++i >= argc) {
97
131
invalid_param = true ;
98
132
break ;
99
133
}
100
134
params.path_session = argv[i];
135
+ =======
136
+ params.prompt = process_escapes (argv[i]);
137
+ >>>>>>> 7f8e899 (Process escape sequences given in prompts)
101
138
} else if (arg == " -f" || arg == " --file" ) {
102
139
if (++i >= argc) {
103
140
invalid_param = true ;
0 commit comments