diff --git a/modelscope/cli/llamafile.py b/modelscope/cli/llamafile.py index 39d1346f..5c52344d 100644 --- a/modelscope/cli/llamafile.py +++ b/modelscope/cli/llamafile.py @@ -55,15 +55,6 @@ class LlamafileCMD(CLICommand): 'Selected accuracy of GGUF files in the repo. Ignored when "file" is also provided.' ) - group.add_argument( - '--launch', - type=str, - required=False, - default='True', - help= - 'Whether to launch model with the downloaded llamafile, default to True.' - ) - group.add_argument( '--file', type=str, @@ -80,6 +71,15 @@ class LlamafileCMD(CLICommand): 'Directory where the selected llamafile would will be downloaded to.' ) + group.add_argument( + '--launch', + type=str, + required=False, + default='True', + help= + 'Whether to launch model with the downloaded llamafile, default to True.' + ) + parser.set_defaults(func=subparser_func) def execute(self): @@ -106,7 +106,7 @@ class LlamafileCMD(CLICommand): selected_file = f found = True break - if self.args.accuracy and self.args.accuracy in f.lower(): + if self.args.accuracy and self.args.accuracy.lower() in f.lower(): selected_file = f found = True break diff --git a/tests/cli/test_llamfafile_cmd.py b/tests/cli/test_llamfafile_cmd.py index 616ed78c..d0ff7574 100644 --- a/tests/cli/test_llamfafile_cmd.py +++ b/tests/cli/test_llamfafile_cmd.py @@ -29,6 +29,24 @@ class LlamafileCMDTest(unittest.TestCase): in output) self.assertTrue('Launching model with llamafile' in output) + accuracy = 'Q2_K' + cmd = f'python -m modelscope.cli.cli {self.cmd} --model {self.model_id} --accuracy {accuracy}' + stat, output = subprocess.getstatusoutput(cmd) + self.assertEqual(stat, 0) + self.assertTrue( + 'llamafile matching criteria found: [My-Model-14B-Q2_K.llamafile]' + in output) + self.assertTrue('Launching model with llamafile' in output) + + accuracy = 'q2_k' + cmd = f'python -m modelscope.cli.cli {self.cmd} --model {self.model_id} --accuracy {accuracy}' + stat, output = subprocess.getstatusoutput(cmd) + self.assertEqual(stat, 0) + self.assertTrue( + 'llamafile matching criteria found: [My-Model-14B-Q2_K.llamafile]' + in output) + self.assertTrue('Launching model with llamafile' in output) + def test_given_file(self): file = 'My-Model-14B-FP16.llamafile' cmd = f'python -m modelscope.cli.cli {self.cmd} --model {self.model_id} --file {file}'