diff --git a/scripts/edit-os b/scripts/edit-os index 447fa93..ec90a6f 100755 --- a/scripts/edit-os +++ b/scripts/edit-os @@ -132,16 +132,32 @@ EOF ) echo "🧠 Generating commit message with Ollama ($OLLAMA_MODEL)..." + local json_payload + json_payload=$(jq -n \ + --arg model "$OLLAMA_MODEL" \ + --arg prompt "$prompt" \ + '{ + model: $model, + prompt: $prompt, + stream: false, + options: { + temperature: 0.3, + num_predict: 150 + } + }') + + # Check if jq failed (e.g., if variables were not set properly for jq) + if [ -z "$json_payload" ]; then + echo "Error: Failed to create JSON payload with jq." >&2 + return + fi + local ollama_response - ollama_response=$(curl -s --fail "$OLLAMA_HOST/api/generate" -d '{ - "model": "'"$OLLAMA_MODEL"'", - "prompt": "'"${prompt//\"/\\\"}"'", - "stream": false, - "options": { - "temperature": 0.3, - "num_predict": 150 - } - }') + ollama_response=$(curl -s --fail \ + -X POST \ + -H "Content-Type: application/json" \ + --data "$json_payload" \ + "$OLLAMA_HOST/api/generate") if [ -z "$ollama_response" ]; then echo "❌ Ollama request failed or returned empty. Using default commit message." @@ -247,5 +263,3 @@ echo "-----------------------------------------------------" _cleanup # Call cleanup function echo "🎉 All done!" - -