-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaskai.sh
executable file
·47 lines (39 loc) · 981 Bytes
/
askai.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# The path to your Python script
python_script_path="./ask-ai.py"
# Function to display usage
usage() {
echo "Usage: $0 [--model MODEL] [--q QUERY] [--c chat mode]"
exit 1
}
# Initialize variables for command-line arguments
QUERY=""
CHAT_MODE=""
MODEL=""
# Parse command-line arguments
while [ $# -gt 0 ]; do
case "$1" in
--q) QUERY="$2"; shift ;;
--c) CHAT_MODE="--c";;
--model) MODEL="--model $2"; shift ;;
--help) usage ;;
*) echo "Unknown argument: $1"; usage ;;
esac
shift
done
# Construct the final command with arguments to run the Python script
cmd="python3 \"$python_script_path\""
# Append arguments to the command if they are set
if [ ! -z "$MODEL" ]; then
cmd="$cmd $MODEL"
fi
if [ ! -z "$QUERY" ]; then
cmd="$cmd --q \"$QUERY\""
fi
if [ ! -z "$CHAT_MODE" ]; then
cmd="$cmd $CHAT_MODE"
fi
# Run the Python script with the constructed command
eval $cmd
# Exit the script
exit 0