feat(ai): implement typora flag
This commit is contained in:
parent
e6e81ec81a
commit
1f37cbb70b
1 changed files with 25 additions and 3 deletions
28
ai.sh
28
ai.sh
|
|
@ -9,10 +9,32 @@ model=$helper
|
||||||
modelfile=$helper_modelfile
|
modelfile=$helper_modelfile
|
||||||
|
|
||||||
# Initialize variables
|
# Initialize variables
|
||||||
typora_flag=false
|
|
||||||
other_args=${@:2}
|
other_args=${@:2}
|
||||||
|
typora_flag=false
|
||||||
|
|
||||||
# TODO: extract typora flag
|
# Parse options
|
||||||
|
while getopts "t" opt; do
|
||||||
|
case "$opt" in
|
||||||
|
t)
|
||||||
|
typora_flag=true # -t was given
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# parse string args (when used as a function and passed "$@")
|
||||||
|
POSITIONAL_ARGS=()
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
-t)
|
||||||
|
typora_flag=true
|
||||||
|
shift # past argument
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
POSITIONAL_ARGS+=("$1") # save positional arg
|
||||||
|
shift # past argument
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if ! [ "$other_args" = "" ]; then
|
if ! [ "$other_args" = "" ]; then
|
||||||
if [ "$other_args" = "open-webui" ]; then
|
if [ "$other_args" = "open-webui" ]; then
|
||||||
|
|
@ -53,7 +75,7 @@ if ! [ "$other_args" = "" ]; then
|
||||||
# If -t flag is set, use typora to display output
|
# If -t flag is set, use typora to display output
|
||||||
if [ "$typora_flag" = true ]; then
|
if [ "$typora_flag" = true ]; then
|
||||||
tempfile="$(mktemp)"
|
tempfile="$(mktemp)"
|
||||||
OLLAMA_HOST=$host ollama run $model "$other_args" > $tempfile
|
OLLAMA_HOST=$host ollama run $model "$other_args" --hidethinking > $tempfile
|
||||||
typora $tempfile > /dev/null 2>/dev/null &
|
typora $tempfile > /dev/null 2>/dev/null &
|
||||||
else
|
else
|
||||||
# If no -t flag, just run the command normally
|
# If no -t flag, just run the command normally
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue