char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
e9b6350e6
char/aliceai-t5-moe
1#!/usr/bin/env bash 2# 3# Shortcut for downloading HF models 4# 5# Usage: 6# ./llama-cli -m $(./scripts/hf.sh https://huggingface.co/TheBloke/Mixtral-8x7B-v0.1-GGUF/resolve/main/mixtral-8x7b-v0.1.Q4_K_M.gguf) 7# ./llama-cli -m $(./scripts/hf.sh --url https://huggingface.co/TheBloke/Mixtral-8x7B-v0.1-GGUF/blob/main/mixtral-8x7b-v0.1.Q4_K_M.gguf) 8# ./llama-cli -m $(./scripts/hf.sh --repo TheBloke/Mixtral-8x7B-v0.1-GGUF --file mixtral-8x7b-v0.1.Q4_K_M.gguf) 9# 10 11# all logs go to stderr 12function log { 13echo " $ @" 1 >&2 14} 15 16function usage { 17log "Usage: $ 0 [[--url] <url>] [--repo <repo>] [--file <file>] [--outdir <dir> [-h|--help]" 18exit 1 19} 20 21# check for curl or wget 22function has_cmd { 23if ! [ -x" $( command -v $ 1 ) " ];then 24return 1 25fi 26} 27 28if has_cmd wget;then 29cmd ="wget -q -c -O %s/%s %s" 30elif has_cmd curl;then 31cmd ="curl -C - -f --output-dir %s -o %s -L %s" 32else 33log "[E] curl or wget not found" 34exit 1 35fi 36 37url ="" 38repo ="" 39file ="" 40outdir ="." 41 42# parse args 43while [[$ # -gt 0 ]];do 44case " $ 1 " in 45 --url) 46url =" $ 2 " 47shift 2 48 ;; 49 --repo) 50repo =" $ 2 " 51shift 2 52 ;; 53 --file) 54file =" $ 2 " 55shift 2 56 ;; 57 --outdir) 58outdir =" $ 2 " 59shift 2 60 ;; 61 -h| --help) 62usage 63 ;; 64 *) 65url =" $ 1 " 66shift 67 ;; 68esac 69done 70 71if [ -n" $ repo " ]&& [ -n" $ file " ];then 72url ="https://huggingface.co/ $ repo /resolve/main/ $ file " 73fi 74 75if [ -z" $ url " ];then 76log "[E] missing --url" 77usage 78fi 79 80# check if the URL is a HuggingFace model, and if so, try to download it 81is_url =false 82 83if [[${# url } -gt 22 ]];then 84if [[${ url :0:22} =="https://huggingface.co" ]];then 85is_url =true 86fi 87fi 88 89if [" $ is_url " = false ];then 90log "[E] invalid URL, must start with https://huggingface.co" 91exit 0 92fi 93 94# replace "blob/main" with "resolve/main" 95url =${ url /blob\/main/resolve\/main} 96 97basename =$( basename $ url ) 98 99log "[+] attempting to download $ basename " 100 101if [ -n" $ cmd " ];then 102cmd =$( printf " $ cmd " " $ outdir " " $ basename " " $ url " ) 103log "[+] $ cmd " 104if $ cmd ;then 105echo $ outdir /$ basename 106exit 0 107fi 108fi 109 110log "[-] failed to download" 111 112exit 1