summaryrefslogtreecommitdiff
path: root/access.sh
blob: adf51fc701cf7a6c224fa6c6aa6fb0e48e0018e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

[ ! -f .env ] || export $(grep -v '^#' .env | xargs)
SERVER="${OLLAMA_HOST:-http://localhost:11434}"
MODEL="${OLLAMA_MODEL:-llama3.2}"
PROMPT=$(cat << EOF
Please clean up the following code, leaving ample documentation:
def test(a: int, b: float) -> int:
  return a + b ** 0.5
EOF
)
RESPONSE=$(curl -s "$SERVER/api/generate" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg model "$MODEL" --arg prompt "$PROMPT" \
        '{model:$model, prompt:$prompt, stream:false}')" \
        | jq -r '.response')
echo "${RESPONSE}"
#curl -s "$SERVER/api/generate" \
#  -H "Content-Type: application/json" \
#  -d "{
#    \"model\": \"$MODEL\",
#    \"prompt\": \"$PROMPT\",
#    \"stream\": false
#  }" | jq -r '.response'