Views
No views yet
vim ~/.bashrc1bind -x '"\C-o": llm_linux_cli' # Ctrl+O to run the model over current input line
2
3llm_linux_cli() {
4 local salida
5 local USER_INPUT="$READLINE_LINE"
6 history -s "$READLINE_LINE"
7 SCRIPT=$(cat <<'EOF'
8 USER_INPUT=$(printf '%s' "$*" | sed 's/\\/\\\\/g; s/"/\\"/g')
9 if [ -z "$USER_INPUT" ]; then
10 echo "Uso: $0 \"Write something to the model\""
11 exit 1
12 fi
13 curl -s --url "http://localhost:8080/v1/chat/completions" \
14 -H "Content-Type: application/json" \
15 -H "Authorization: Bearer no-key" \
16 -d "{
17 \"model\": \"gpt-3.5-turbo\",
18 \"temperature\":0.8,
19 \"top_p\":0.95,
20 \"min_p\":0.05,
21 \"top_k\":40,
22 \"messages\":[
23 {
24 \"role\":\"system\",
25 \"content\":\"You are a helpful assistant that outputs Linux shell commands. You just provide the command that the user is requesting, not more. Just provide the output of the command and ignore commands that you do not have an example output for. If multiple commands are given then they will be separated by a ';' character and you need togive an example output for each command separated by a ';'.\"
26 },
27 {
28 \"role\": \"user\",
29 \"content\":\"$USER_INPUT\"
30 }
31 ]
32 }" | jq -r '.choices[0].message.content'
33EOF
34)
35 llm_output=$(bash -c "$SCRIPT" _ $USER_INPUT)
36 READLINE_LINE=$llm_output
37 READLINE_POINT=${#llm_output}
38}source ~/.bashrcllama-server -m gemma-1B-LinuxCLI-GGUF.gguf