#!/bin/sh

set -e
test -n "$VERBOSE" && set -x

if test -f "$1"/VERSION && test $(cat "$1"/VERSION) = $2; then
  exit
fi

mkdir -p "$1"
cd "$1"

tea gum format <<EoMD
# downloading OpenLLaMA 3Bv2
models will be placed: \`$PWD\`
> this may take a a few minutes…
EoMD

tea wget \
  --continue \
  --output-document OpenLLaMA-3Bv2.ggml.f16.bin \
  'https://huggingface.co/SlyEcho/open_llama_3b_v2_ggml/resolve/main/open-llama-3b-v2-f16.bin'

tea wget \
  --continue \
  'https://huggingface.co/openlm-research/open_llama_3b_v2/resolve/main/tokenizer.model'

echo $2 > VERSION

tea gum format "# All done!"
echo  #spacer
