From 73a9a14d3fa8c9ad1d8906718ba10ed528804d1a Mon Sep 17 00:00:00 2001 From: Andrei Lazarescu Date: Sat, 31 May 2025 00:15:13 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A0=20Generating=20commit=20message=20?= =?UTF-8?q?with=20Ollama=20(deepseek-r1:1.5b)...=20=E2=9A=A0=EF=B8=8F=20Ol?= =?UTF-8?q?lama=20message=20doesn't=20look=20like=20a=20conventional=20com?= =?UTF-8?q?mit.=20Prepending=20'chore:=20'.=20chore:=20=20Alright,?= =?UTF-8?q?=20I=20need=20to=20generate=20a=20Conventional=20Commit=20messa?= =?UTF-8?q?ge=20for=20the=20git=20diff=20provided=20in=20the=20Nix=20confi?= =?UTF-8?q?guration=20repository.=20The=20focus=20is=20on=20the=20commit?= =?UTF-8?q?=20message=20itself.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First, looking at the git diff, it's an edit file, so the changes are in scripts/edit-os. The subject line should be concise and descriptive. Since the change involves generating a commit message using Ollama, I'll use 'feat' for that as it indicates a new feature addition. Next, the scope is determined by the type of change. Here, it's about modifying the commit message generation process, so 'fix' makes sense because we're correcting or updating an existing function. The subject line should be "Fix: Generate Commit Message with Ollama --- scripts/edit-os | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) 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!" - -