#!/bin/sh
# Use first discovered model
if [ ! -f /tmp/model_0.txt ] || [ ! -f /tmp/endpoint_0.txt ]; then
  echo "ERROR: No models discovered"
  exit 1
fi

model=$(cat /tmp/model_0.txt)
endpoint=$(cat /tmp/endpoint_0.txt)

echo "Using model: $model"
echo "Endpoint: $endpoint"

curl -s "${endpoint}/chat/completions" \
  -H 'Content-Type: application/json' \
  -d "{\"model\":\"$model\",\"messages\":[{\"role\":\"system\",\"content\":\"You are Hermes, a helpful AI assistant from Nous Research.\"},{\"role\":\"user\",\"content\":\"Explain quantum computing in one sentence.\"}],\"max_tokens\":100}" \
  2>/dev/null | grep -o '"content":"[^"]*"' | head -1 | cut -d'"' -f4
