URI: 
       gpt - annna - Annna the nice friendly bot.
  HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
       ---
       gpt (2289B)
       ---
            1 #!/bin/sh
            2 
            3 export PATH="$HOME/bin:$PATH"
            4 
            5 # TODO: Remove due to outdated model.
            6 function local_llama() {
            7         #ggmlbase="/br/ai/ggml"
            8         ggmlbase="/br/ai/llama.cpp"
            9         #ggmlbin="./build/bin/gpt-2"
           10         ggmlbin="./build/bin/llama-cli"
           11         #ggmlmodel="models/gpt-2-1558M/ggml-model.bin"
           12         ggmlmodel="models/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf"
           13         ggmlntokens="$((69 * 2))"
           14 
           15         cd $ggmlbase
           16         if mountpoint -q /br/ai/tmp;
           17         then
           18                 ggmlbasename="$(basename "${ggmlmodel}")"
           19                 ggmltmppath="/br/ai/tmp/${ggmlbasename}"
           20                 [ ! -r "${ggmltmppath}" ] && cp "$ggmlmodel" /br/ai/tmp        
           21                 [ -r "${ggmltmppath}" ] && ggmlmodel="${ggmltmppath}"
           22         fi
           23 
           24         prompt="$1"
           25         if [ -z "$prompt" ];
           26         then
           27                 cat \
           28                 | $ggmlbin -m $ggmlmodel -n $ggmlntokens -t 3 \
           29                         --no-warmup --simple-io --no-display-prompt --grammar 'root ::= ([^\x00-\x1F])*' \
           30                         -cnv 2>/dev/null \
           31                         | sed -E '/^$/d;s/^>[[:blank:]]+//;q' \
           32                         | sed -e 's/^"//;s/"$//;'
           33         else
           34                 printf "%s\n" "${prompt}" \
           35                 | $ggmlbin -m $ggmlmodel -n $ggmlntokens -t 3 \
           36                         --no-warmup --simple-io --no-display-prompt --grammar 'root ::= ([^\x00-\x1F])*' \
           37                         -cnv 2>/dev/null \
           38                         | sed -E '/^$/d;s/^>[[:blank:]]+//;q' \
           39                         | sed -e 's/^"//;s/"$//;'
           40         fi
           41         #$ggmlbin -m $ggmlmodel -n $ggmlntokens \
           42         #        --simple-io --no-display-prompt --grammar 'root ::= ([^\x00-\x1F])*' \
           43         #        -p "$1" 2>/dev/null \
           44         #        | head -n1 \
           45         #        | sed -E 's/^[[:blank:]]+//;s/[[:blank:]]*\[end of text\]$//' \
           46         #        | tr -d '"'
           47 }
           48 
           49 function remote_llama() {
           50         prompt="$1"
           51         ggmlmodel="AutumnAurelium/llama3.1-abliterated"
           52         #ggmlmodel="mannix/llama3.1-8b-abliterated"
           53         #ggmlmodel="huihui_ai/gpt-oss-abliterated:20b"
           54         #ggmlmodel="huihui_ai/qwen3-abliterated:16b"
           55         #ggmlmodel="huihui_ai/gemma3-abliterated:12b"
           56         #ggmlmodel="huihui_ai/deepseek-r1-abliterated:14b"
           57         if [ -z "$prompt" ];
           58         then
           59                 cat \
           60                 | ollama-gpu \
           61                         ollama run \
           62                                 --hidethinking \
           63                                 --nowordwrap \
           64                                 "${ggmlmodel}"
           65         else
           66                 printf "%s\n" "${prompt}" \
           67                 | ollama-gpu \
           68                         ollama run \
           69                                 --hidethinking \
           70                                 --nowordwrap \
           71                                 "${ggmlmodel}"
           72         fi
           73 }
           74 
           75 prompt="$1"
           76 response="$(remote_llama "${prompt}")"
           77 [ -z "${response}" ] && response="$(local_llama "${prompt}")"
           78 olines="$(printf "%s\n" "${response}" | wc -l)"
           79 [ $olines -gt 1 ] && response="$(printf "%s\n" "${response}" | bitreich-paste)"
           80 [ -n "${response}" ] && printf "%s\n" "${response}"
           81