1+ from pathlib import Path
2+
13import click
24
5+ from .constants import CONFIG_PATH
36from .utils import ConfigHelper , PrintHelper
47
58
@@ -11,10 +14,15 @@ def config() -> None:
1114
1215@config .command (help = "Reset the config to default" )
1316def reset () -> None :
17+ _reset ()
18+
19+
20+ def _reset (config_path : Path = CONFIG_PATH ) -> None :
21+ """Separate function for testing"""
1422 user_verification = input ("Do you want to reset your config to the default values? [y/Y]? " )
1523
1624 if user_verification .lower () in ["y" , "yes" ]:
17- ConfigHelper ().reset ()
25+ ConfigHelper ().reset (config_path = config_path )
1826 else :
1927 click .echo ("Config not reset. Aborted!" )
2028
@@ -31,6 +39,11 @@ def update() -> None:
3139
3240@update .command ("all" , help = "Interface to update the full default config" )
3341def update_all () -> None :
42+ _update_all ()
43+
44+
45+ def _update_all (config_path : Path = CONFIG_PATH ) -> None :
46+ """Separate function for testing"""
3447 config_helper = ConfigHelper ()
3548 PrintHelper .update_config ()
3649
@@ -62,60 +75,95 @@ def update_all() -> None:
6275 PrintHelper .presence_penalty ()
6376 config_helper .input_presence_penalty ()
6477
65- config_helper .update ()
78+ config_helper .update (config_path = config_path )
6679
6780
6881@update .command (help = "Update model" )
6982def model () -> None :
83+ _model ()
84+
85+
86+ def _model (config_path : Path = CONFIG_PATH ) -> None :
87+ """Separate function for testing"""
7088 PrintHelper .model ()
7189 config_helper = ConfigHelper .from_file ()
7290 config_helper .input_model ()
73- config_helper .update ()
91+ config_helper .update (config_path = config_path )
7492
7593
7694@update .command (help = "Update number of altenative answers generated per question" )
7795def num_answers () -> None :
96+ _num_answers ()
97+
98+
99+ def _num_answers (config_path : Path = CONFIG_PATH ) -> None :
100+ """Separate function for testing"""
78101 PrintHelper .num_answers ()
79102 config_helper = ConfigHelper .from_file ()
80103 config_helper .input_num_answer ()
81- config_helper .update ()
104+ config_helper .update (config_path = config_path )
82105
83106
84107@update .command (help = "Update maximum number of tokens" )
85108def max_tokens () -> None :
109+ _max_tokens ()
110+
111+
112+ def _max_tokens (config_path : Path = CONFIG_PATH ) -> None :
113+ """Separate function for testing"""
86114 PrintHelper .max_tokens ()
87115 config_helper = ConfigHelper ().from_file ()
88116 config_helper .input_max_token ()
89- config_helper .update ()
117+ config_helper .update (config_path = config_path )
90118
91119
92120@update .command (help = "Update temperature" )
93121def temperature () -> None :
122+ _temperature ()
123+
124+
125+ def _temperature (config_path : Path = CONFIG_PATH ) -> None :
126+ """Separate function for testing"""
94127 PrintHelper .temperature ()
95128 config_helper = ConfigHelper ().from_file ()
96129 config_helper .input_temperature ()
97- config_helper .update ()
130+ config_helper .update (config_path = config_path )
98131
99132
100133@update .command (help = "Update top_p" )
101134def top_p () -> None :
135+ _top_p ()
136+
137+
138+ def _top_p (config_path : Path = CONFIG_PATH ) -> None :
139+ """Separate function for testing"""
102140 PrintHelper .top_p ()
103141 config_helper = ConfigHelper ().from_file ()
104142 config_helper .input_top_p ()
105- config_helper .update ()
143+ config_helper .update (config_path = config_path )
106144
107145
108146@update .command (help = "Update frequency penalty" )
109147def frequency_penalty () -> None :
148+ _frequency_penalty ()
149+
150+
151+ def _frequency_penalty (config_path : Path = CONFIG_PATH ) -> None :
152+ """Separate function for testing"""
110153 PrintHelper .frequency_penalty ()
111154 config_helper = ConfigHelper .from_file ()
112155 config_helper .input_frequency_penalty ()
113- config_helper .update ()
156+ config_helper .update (config_path = config_path )
114157
115158
116159@update .command (help = "Update presence penalty" )
117160def presence_penalty () -> None :
161+ _frequency_penalty ()
162+
163+
164+ def _presence_penalty (config_path : Path = CONFIG_PATH ) -> None :
165+ """Separate function for testing"""
118166 PrintHelper .presence_penalty ()
119167 config_helper = ConfigHelper .from_file ()
120168 config_helper .input_presence_penalty ()
121- config_helper .update ()
169+ config_helper .update (config_path = config_path )
0 commit comments