#!/bin/bash
RULES="You are a helpful agent, providing all answers with less than 25 words"

read -p "Please enter your question: " QUESTION

DATA='{
    "model": "docker.io/ai/smollm2:360M-Q4_K_M",
    "messages": [
	  {"role": "system", "content": "%s"},
      {"role": "user", "content": "%s"}
    ]
  }'
DATA=$(printf "$DATA" "$RULES" "$QUESTION")

ANSWER=`curl -s http://localhost:12434/engines/v1/chat/completions \
  -X POST \
  -H "Content-Type: application/json" \
  -d "$DATA"`

CONTENT=`echo $ANSWER | sed -n 's/.*"content":"\([^"]*\)".*/\1/p'`

echo $CONTENT
