File size: 973 Bytes
6a8d17c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# if conf does not exist, create it
if [ ! -f "$HOME/.config/llama/llama-prompt.conf" ]; then
    mkdir -p "$HOME/.config/llama"
    cat <<EOF > "$HOME/.config/llama/llama-prompt.conf"
LLAMA_MODEL_NAME=$HOME/.ai/models/llama/teknium/OpenHermes-2.5-Mistral-7B/openhermes-2.5-mistral-7b-f16.gguf
LLAMA_CONTEXT_SIZE=8192
EOF
fi

source "$HOME/.config/llama/llama-prompt.conf"

# if an extra argument is provided, use it for LLAMA_MODEL_NAME
if [ -n "$2" ]; then
    LLAMA_MODEL_NAME="$2"
fi

# if an extra argument is provided, use it for LLAMA_CONTEXT_SIZE
if [ -n "$3" ]; then
    LLAMA_CONTEXT_SIZE="$3"
fi

# if no arguments are provided, print an error message and exit
if [ -z "$1" ]; then
    echo "Usage: llama-prompt.sh <prompt> [model] [context_size]"
    exit 1
fi

llama \
    --file "$1" \
    --model "$LLAMA_MODEL_NAME" \
    --ctx-size "$LLAMA_CONTEXT_SIZE" \
    --mirostat 2 \
    --repeat-last-n 64 \
    --log-disable 2> /dev/null | fmt -w 80