Skip to content

Commit

Permalink
Merge pull request #230 from NexaAI/perry/convert-and-quantize
Browse files Browse the repository at this point in the history
fixed nexa convert cli cannot convert .gguf bug
  • Loading branch information
zhiyuan8 authored Nov 11, 2024
2 parents 2ffbe20 + dc795bc commit 84dd847
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 11 additions & 4 deletions nexa/cli/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,24 @@ def run_convert(args):

input_path = args.input_path

# Check if input_path is a valid directory
if not os.path.isdir(input_path):
# Check input path conditions
if os.path.isdir(input_path):
# Valid directory, proceed as is
pass
elif os.path.isfile(input_path) and input_path.endswith('.gguf'):
# Valid GGUF file, proceed as is
pass
else:
# Try downloading from HF if path isn't a valid local directory/file
from nexa.general import download_repo_from_hf
success, local_path = download_repo_from_hf(input_path)

if success:
input_path = local_path
else:
print("Error: Failed to download the repository and the provided path is not a valid directory.")
print("Error: Input path must be either a directory, a .gguf file, or a valid Hugging Face model identifier.")
return

# Input_path here should be a valid directory
kwargs = {k: v for k, v in vars(args).items() if v is not None and k not in ['input_path', 'ftype', 'output_file', 'convert_type']}

Expand Down
2 changes: 2 additions & 0 deletions nexa/gguf/converter/nexa_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def convert_hf_to_quantized_gguf(
# Set default output file if not provided
if not output_file:
input_name = os.path.basename(input_path)
if input_path.endswith('.gguf'):
input_name = os.path.splitext(input_name)[0] # Remove .gguf extension
output_file = os.path.abspath(f"./{input_name}-{ftype}.gguf")
else:
output_file = os.path.abspath(output_file)
Expand Down

0 comments on commit 84dd847

Please sign in to comment.