Skip to content

Use getopts for example scripts #664

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions examples/chat-13B.sh
Original file line number Diff line number Diff line change
@@ -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";;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not doing it like this for consistency:

Suggested change
m) MODEL="--model $OPTARG";;
m) 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

Expand All @@ -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
./main $GEN_OPTIONS \
--model "$MODEL" \
$MODEL \
--threads "$N_THREAD" \
--n_predict "$N_PREDICTS" \
--color --interactive \
Expand Down
19 changes: 11 additions & 8 deletions examples/reason-act.sh
Original file line number Diff line number Diff line change
@@ -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`
cd ..
shift $((OPTIND-1))

# get -m model parameter otherwise defer to default
if [ "$1" == "-m" ]; then
MODEL="-m $2 "
fi
cd "$(dirname "$0")"
cd ..

./main $MODEL --color \
./bin/main $MODEL --color \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example scripts are meant to be run from the source root, so this has to remain ./main

-f ./prompts/reason-act.txt \
-i --interactive-first \
--top_k 10000 --temp 0.2 --repeat_penalty 1 -t 7 -c 2048 \
Expand Down