Skip to content

Commit 416fa39

Browse files
committed
feat: set option setters to public
1 parent aa1d785 commit 416fa39

File tree

1 file changed

+79
-79
lines changed

1 file changed

+79
-79
lines changed

src/options.rs

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ pub struct ModelOptions {
1818
impl Default for ModelOptions {
1919
fn default() -> Self {
2020
Self {
21-
context_size: 512,
21+
context_size: 128,
2222
seed: 0,
23-
f16_memory: false,
23+
f16_memory: true,
2424
m_lock: false,
2525
embeddings: false,
2626
low_vram: false,
@@ -35,51 +35,51 @@ impl Default for ModelOptions {
3535
}
3636
}
3737

38-
struct PredictOptions {
39-
seed: i32,
40-
threads: i32,
41-
tokens: i32,
42-
top_k: i32,
43-
repeat: i32,
44-
batch: i32,
45-
n_keep: i32,
46-
top_p: f64,
47-
temperature: f64,
48-
penalty: f64,
49-
f16_kv: bool,
50-
debug_mode: bool,
51-
stop_prompts: Vec<String>,
52-
ignore_eos: bool,
53-
54-
tail_free_sampling_z: f64,
55-
typical_p: f64,
56-
frequency_penalty: f64,
57-
presence_penalty: f64,
58-
mirostat: i32,
59-
mirostat_eta: f64,
60-
mirostat_tau: f64,
61-
penalize_nl: bool,
62-
logit_bias: String,
63-
token_callback: Box<dyn Fn(String) -> bool>,
64-
65-
path_prompt_cache: String,
66-
m_lock: bool,
67-
m_map: bool,
68-
prompt_cache_all: bool,
69-
prompt_cache_ro: bool,
70-
main_gpu: String,
71-
tensor_split: String,
38+
pub struct PredictOptions {
39+
pub seed: i32,
40+
pub threads: i32,
41+
pub tokens: i32,
42+
pub top_k: i32,
43+
pub repeat: i32,
44+
pub batch: i32,
45+
pub n_keep: i32,
46+
pub top_p: f32,
47+
pub temperature: f32,
48+
pub penalty: f32,
49+
pub f16_kv: bool,
50+
pub debug_mode: bool,
51+
pub stop_prompts: Vec<String>,
52+
pub ignore_eos: bool,
53+
54+
pub tail_free_sampling_z: f32,
55+
pub typical_p: f32,
56+
pub frequency_penalty: f32,
57+
pub presence_penalty: f32,
58+
pub mirostat: i32,
59+
pub mirostat_eta: f32,
60+
pub mirostat_tau: f32,
61+
pub penalize_nl: bool,
62+
pub logit_bias: String,
63+
pub token_callback: Box<dyn Fn(String) -> bool>,
64+
65+
pub path_prompt_cache: String,
66+
pub m_lock: bool,
67+
pub m_map: bool,
68+
pub prompt_cache_all: bool,
69+
pub prompt_cache_ro: bool,
70+
pub main_gpu: String,
71+
pub tensor_split: String,
7272
}
7373

7474
impl Default for PredictOptions {
7575
fn default() -> Self {
7676
Self {
7777
seed: -1,
78-
threads: 4,
78+
threads: 8,
7979
tokens: 128,
8080
top_k: 40,
8181
repeat: 64,
82-
batch: 8,
82+
batch: 512,
8383
n_keep: 64,
8484
top_p: 0.95,
8585
temperature: 0.8,
@@ -110,169 +110,169 @@ impl Default for PredictOptions {
110110
}
111111

112112
impl ModelOptions {
113-
fn set_context(&mut self, context_size: i32) {
113+
pub fn set_context(&mut self, context_size: i32) {
114114
self.context_size = context_size;
115115
}
116116

117-
fn set_model_seed(&mut self, seed: i32) {
117+
pub fn set_model_seed(&mut self, seed: i32) {
118118
self.seed = seed;
119119
}
120120

121-
fn enable_f16_memory(&mut self) {
121+
pub fn enable_f16_memory(&mut self) {
122122
self.f16_memory = true;
123123
}
124124

125-
fn enable_embeddings(&mut self) {
125+
pub fn enable_embeddings(&mut self) {
126126
self.embeddings = true;
127127
}
128128

129-
fn enable_m_lock(&mut self) {
129+
pub fn enable_m_lock(&mut self) {
130130
self.m_lock = true;
131131
}
132132

133-
fn set_m_map(&mut self, m_map: bool) {
133+
pub fn set_m_map(&mut self, m_map: bool) {
134134
self.m_map = m_map;
135135
}
136136

137-
fn set_n_batch(&mut self, n_batch: i32) {
137+
pub fn set_n_batch(&mut self, n_batch: i32) {
138138
self.n_batch = n_batch;
139139
}
140140

141-
fn set_tensor_split(&mut self, tensor_split: String) {
141+
pub fn set_tensor_split(&mut self, tensor_split: String) {
142142
self.tensor_split = tensor_split;
143143
}
144144

145-
fn set_gpu_layers(&mut self, n_gpu_layers: i32) {
145+
pub fn set_gpu_layers(&mut self, n_gpu_layers: i32) {
146146
self.n_gpu_layers = n_gpu_layers;
147147
}
148148

149-
fn set_main_gpu(&mut self, main_gpu: String) {
149+
pub fn set_main_gpu(&mut self, main_gpu: String) {
150150
self.main_gpu = main_gpu;
151151
}
152152
}
153153

154154
impl PredictOptions {
155-
fn set_prediction_tensor_split(&mut self, tensor_split: String) {
155+
pub fn set_prediction_tensor_split(&mut self, tensor_split: String) {
156156
self.tensor_split = tensor_split;
157157
}
158158

159-
fn set_prediction_main_gpu(&mut self, main_gpu: String) {
159+
pub fn set_prediction_main_gpu(&mut self, main_gpu: String) {
160160
self.main_gpu = main_gpu;
161161
}
162162

163-
fn enable_f16_kv(&mut self) {
163+
pub fn enable_f16_kv(&mut self) {
164164
self.f16_kv = true;
165165
}
166166

167-
fn enable_debug_mode(&mut self) {
167+
pub fn enable_debug_mode(&mut self) {
168168
self.debug_mode = true;
169169
}
170170

171-
fn enable_prompt_cache_all(&mut self) {
171+
pub fn enable_prompt_cache_all(&mut self) {
172172
self.prompt_cache_all = true;
173173
}
174174

175-
fn enable_prompt_cache_ro(&mut self) {
175+
pub fn enable_prompt_cache_ro(&mut self) {
176176
self.prompt_cache_ro = true;
177177
}
178178

179-
fn enable_m_lock(&mut self) {
179+
pub fn enable_m_lock(&mut self) {
180180
self.m_lock = true;
181181
}
182182

183-
fn set_m_lock(&mut self, m_lock: bool) {
183+
pub fn set_m_lock(&mut self, m_lock: bool) {
184184
self.m_lock = m_lock;
185185
}
186186

187-
fn set_memory_map(&mut self, m_map: bool) {
187+
pub fn set_memory_map(&mut self, m_map: bool) {
188188
self.m_map = m_map;
189189
}
190190

191-
fn set_token_callback(&mut self, token_callback: Box<dyn Fn(String) -> bool>) {
191+
pub fn set_token_callback(&mut self, token_callback: Box<dyn Fn(String) -> bool>) {
192192
self.token_callback = token_callback;
193193
}
194194

195-
fn set_path_prompt_cache(&mut self, path_prompt_cache: String) {
195+
pub fn set_path_prompt_cache(&mut self, path_prompt_cache: String) {
196196
self.path_prompt_cache = path_prompt_cache;
197197
}
198198

199-
fn set_seed(&mut self, seed: i32) {
199+
pub fn set_seed(&mut self, seed: i32) {
200200
self.seed = seed;
201201
}
202202

203-
fn set_threads(&mut self, threads: i32) {
203+
pub fn set_threads(&mut self, threads: i32) {
204204
self.threads = threads;
205205
}
206206

207-
fn set_tokens(&mut self, tokens: i32) {
207+
pub fn set_tokens(&mut self, tokens: i32) {
208208
self.tokens = tokens;
209209
}
210210

211-
fn set_top_k(&mut self, top_k: i32) {
211+
pub fn set_top_k(&mut self, top_k: i32) {
212212
self.top_k = top_k;
213213
}
214214

215-
fn set_repeat(&mut self, repeat: i32) {
215+
pub fn set_repeat(&mut self, repeat: i32) {
216216
self.repeat = repeat;
217217
}
218218

219-
fn set_batch(&mut self, batch: i32) {
219+
pub fn set_batch(&mut self, batch: i32) {
220220
self.batch = batch;
221221
}
222222

223-
fn set_n_keep(&mut self, n_keep: i32) {
223+
pub fn set_n_keep(&mut self, n_keep: i32) {
224224
self.n_keep = n_keep;
225225
}
226226

227-
fn set_top_p(&mut self, top_p: f64) {
227+
pub fn set_top_p(&mut self, top_p: f32) {
228228
self.top_p = top_p;
229229
}
230230

231-
fn set_temperature(&mut self, temperature: f64) {
231+
pub fn set_temperature(&mut self, temperature: f32) {
232232
self.temperature = temperature;
233233
}
234234

235-
fn set_penalty(&mut self, penalty: f64) {
235+
pub fn set_penalty(&mut self, penalty: f32) {
236236
self.penalty = penalty;
237237
}
238238

239-
fn set_tail_free_sampling_z(&mut self, tail_free_sampling_z: f64) {
239+
pub fn set_tail_free_sampling_z(&mut self, tail_free_sampling_z: f32) {
240240
self.tail_free_sampling_z = tail_free_sampling_z;
241241
}
242242

243-
fn set_typical_p(&mut self, typical_p: f64) {
243+
pub fn set_typical_p(&mut self, typical_p: f32) {
244244
self.typical_p = typical_p;
245245
}
246246

247-
fn set_frequency_penalty(&mut self, frequency_penalty: f64) {
247+
pub fn set_frequency_penalty(&mut self, frequency_penalty: f32) {
248248
self.frequency_penalty = frequency_penalty;
249249
}
250250

251-
fn set_presence_penalty(&mut self, presence_penalty: f64) {
251+
pub fn set_presence_penalty(&mut self, presence_penalty: f32) {
252252
self.presence_penalty = presence_penalty;
253253
}
254254

255-
fn set_mirostat(&mut self, mirostat: i32) {
255+
pub fn set_mirostat(&mut self, mirostat: i32) {
256256
self.mirostat = mirostat;
257257
}
258258

259-
fn set_mirostat_eta(&mut self, mirostat_eta: f64) {
259+
pub fn set_mirostat_eta(&mut self, mirostat_eta: f32) {
260260
self.mirostat_eta = mirostat_eta;
261261
}
262262

263-
fn set_mirostat_tau(&mut self, mirostat_tau: f64) {
263+
pub fn set_mirostat_tau(&mut self, mirostat_tau: f32) {
264264
self.mirostat_tau = mirostat_tau;
265265
}
266266

267-
fn enable_penalize_nl(&mut self) {
267+
pub fn enable_penalize_nl(&mut self) {
268268
self.penalize_nl = true;
269269
}
270270

271-
fn set_logit_bias(&mut self, logit_bias: String) {
271+
pub fn set_logit_bias(&mut self, logit_bias: String) {
272272
self.logit_bias = logit_bias;
273273
}
274274

275-
fn ignore_eos(&mut self) {
275+
pub fn ignore_eos(&mut self) {
276276
self.ignore_eos = true;
277277
}
278278
}

0 commit comments

Comments
 (0)