Use getopts for example scripts

This commit is contained in:
Ben Siraphob 2023-03-31 17:37:33 -05:00
parent 3525899277
commit b09da81d52
No known key found for this signature in database
GPG key ID: 45F0E5D788143267
2 changed files with 27 additions and 10 deletions

View file

@ -1,4 +1,18 @@
#!/bin/bash #!/usr/env/bin bash
while getopts "m:u:a:t:p:g:" opt; do
case $opt in
m) MODEL="--model $OPTARG";;
u) USER_NAME="$OPTARG";;
a) AI_NAME="$OPTARG";;
t) N_THREAD="$OPTARG";;
p) N_PREDICTS="$OPTARG";;
g) GEN_OPTIONS="$OPTARG";;
\?) echo "Invalid option -$OPTARG" >&2; exit 1;;
esac
done
shift $((OPTIND-1))
cd "$(dirname "$0")/.." || exit cd "$(dirname "$0")/.." || exit
@ -17,7 +31,7 @@ GEN_OPTIONS="${GEN_OPTIONS:---ctx_size 2048 --temp 0.7 --top_k 40 --top_p 0.5 --
# shellcheck disable=SC2086 # Intended splitting of GEN_OPTIONS # shellcheck disable=SC2086 # Intended splitting of GEN_OPTIONS
./main $GEN_OPTIONS \ ./main $GEN_OPTIONS \
--model "$MODEL" \ $MODEL \
--threads "$N_THREAD" \ --threads "$N_THREAD" \
--n_predict "$N_PREDICTS" \ --n_predict "$N_PREDICTS" \
--color --interactive \ --color --interactive \

View file

@ -1,15 +1,18 @@
#!/usr/env/bin bash
#!/bin/bash while getopts "m:" opt; do
case $opt in
m) MODEL="-m $OPTARG";;
\?) echo "Invalid option -$OPTARG" >&2; exit 1;;
esac
done
cd `dirname $0` shift $((OPTIND-1))
cd "$(dirname "$0")"
cd .. cd ..
# get -m model parameter otherwise defer to default ./bin/main $MODEL --color \
if [ "$1" == "-m" ]; then
MODEL="-m $2 "
fi
./main $MODEL --color \
-f ./prompts/reason-act.txt \ -f ./prompts/reason-act.txt \
-i --interactive-first \ -i --interactive-first \
--top_k 10000 --temp 0.2 --repeat_penalty 1 -t 7 -c 2048 \ --top_k 10000 --temp 0.2 --repeat_penalty 1 -t 7 -c 2048 \