MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / main

Function main

docker/open_llama/hug_model.py:73–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71 return None
72
73def main():
74 # Create an argument parser
75 parser = argparse.ArgumentParser(description='Process some parameters.')
76
77 # Arguments
78 parser.add_argument('-v', '--version', type=int, default=0x0003,
79 help='hexadecimal version number of ggml file')
80 parser.add_argument('-a', '--author', type=str, default='TheBloke',
81 help='HuggingFace author filter')
82 parser.add_argument('-t', '--tag', type=str, default='llama',
83 help='HuggingFace tag filter')
84 parser.add_argument('-s', '--search', type=str, default='',
85 help='HuggingFace search filter')
86 parser.add_argument('-f', '--filename', type=str, default='q5_1',
87 help='HuggingFace model repository filename substring match')
88
89 # Parse the arguments
90 args = parser.parse_args()
91
92 # Define the parameters
93 params = {
94 "author": args.author,
95 "tags": args.tag,
96 "search": args.search
97 }
98
99 models = make_request('https://huggingface.co/api/models', params=params)
100 if models is None:
101 return
102
103 model_list = []
104 # Iterate over the models
105 for model in models:
106 model_id = model['id']
107 model_info = make_request(f'https://huggingface.co/api/models/{model_id}')
108 if model_info is None:
109 continue
110
111 for sibling in model_info.get('siblings', []):
112 rfilename = sibling.get('rfilename')
113 if rfilename and args.filename in rfilename:
114 model_list.append((model_id, rfilename))
115
116 # Choose the model
117 model_list.sort(key=lambda x: x[0])
118 if len(model_list) == 0:
119 print("No models found")
120 exit(1)
121 elif len(model_list) == 1:
122 model_choice = model_list[0]
123 else:
124 model_choice = get_user_choice(model_list)
125
126 if model_choice is not None:
127 model_id, rfilename = model_choice
128 url = f"https://huggingface.co/{model_id}/resolve/main/{rfilename}"
129 dest = f"{model_id.replace('/', '_')}_{rfilename}"
130 download_file(url, dest)

Callers 1

hug_model.pyFile · 0.70

Calls 5

make_requestFunction · 0.85
get_user_choiceFunction · 0.85
download_fileFunction · 0.85
check_magic_and_versionFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…