🧠 Generating commit message with Ollama (deepseek-r1:1.5b)...

⚠️ Ollama message doesn't look like a conventional commit. Prepending 'chore: '.
chore: <think>
Alright, I need to generate a Conventional Commit message for the git diff provided in the Nix configuration repository. The focus is on the commit message itself.

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
This commit is contained in:
Andrei Lazarescu 2025-05-31 00:15:13 +03:00
parent 709e94f5a0
commit 73a9a14d3f

View File

@ -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!"